full_path
stringlengths 31
232
| filename
stringlengths 4
167
| content
stringlengths 0
48.3M
|
|---|---|---|
PowerShellCorpus/PowerShellGallery/xAzurePack/1.4.0.0/Examples/AzurePack_splitroles_example.ps1
|
AzurePack_splitroles_example.ps1
|
$InstallerPassword = ConvertTo-SecureString -String 'P@ssw0rd123!' -AsPlainText -Force
$ServerAdminPassword = ConvertTo-SecureString -String 'P@ssw0rd123!' -AsPlainText -Force
$WAPPassphrase = ConvertTo-SecureString -String 'P@ssw0rd123!' -AsPlainText -Force
Configuration Example_WindowsAzurePack
{
Import-DscResource -Module xSQLServer
Import-DscResource -Module xCredSSP
Import-DscResource -Module xAzurePack
Import-DscResource -Module PSDesiredStateConfiguration
Import-DscResource -Module xWebAdministration
Import-DscResource -Module cManageCertificates
# Set role and instance variables
$Roles = $AllNodes.Roles | Sort-Object -Unique
foreach($Role in $Roles)
{
$Servers = @($AllNodes.Where{
$_.Roles | Where-Object -FilterScript {
$_ -eq $Role
}
}.NodeName)
Set-Variable -Name ($Role.Replace(' ','').Replace('.','') + 's') -Value $Servers
if($Servers.Count -eq 1)
{
Set-Variable -Name ($Role.Replace(' ','').Replace('.','')) -Value $Servers[0]
if(
$Role.Contains('Database') -or
$Role.Contains('Datawarehouse') -or
$Role.Contains('Reporting') -or
$Role.Contains('Analysis') -or
$Role.Contains('Integration')
)
{
$Instance = $AllNodes.Where{
$_.NodeName -eq $Servers[0]
}.SQLServers.Where{
$_.Roles | Where-Object -FilterScript {
$_ -eq $Role
}
}.InstanceName
Set-Variable -Name ($Role.Replace(' ','').Replace('.','').Replace('Server','Instance')) -Value $Instance
}
}
}
Node $AllNodes.NodeName
{
# Enable CredSSP
if(
($WindowsAzurePack2013AdminAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantPublicAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013SQLServerExtensionServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013MySQLExtensionServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013AdminSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013AdminAuthenticationServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantAuthenticationSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
xCredSSP 'Server'
{
Ensure = 'Present'
Role = 'Server'
}
xCredSSP 'Client'
{
Ensure = 'Present'
Role = 'Client'
DelegateComputers = $Node.NodeName
}
}
# Install .NET Framework 3.5 on SQL nodes
if(
($WindowsAzurePack2013DatabaseServer -eq $Node.NodeName) -or
($WindowsAzurePack2013AdminAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantPublicAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013SQLServerExtensionServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013MySQLExtensionServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013AdminSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013AdminAuthenticationServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantAuthenticationSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($SQLServer2014ManagementTools | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
WindowsFeature 'NETFrameworkCore'
{
Ensure = 'Present'
Name = 'NET-Framework-Core'
}
}
# Install IIS
if(
($WindowsAzurePack2013AdminAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantPublicAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013SQLServerExtensionServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013MySQLExtensionServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013AdminSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013AdminAuthenticationServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantAuthenticationSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
WindowsFeature 'Web-WebServer'
{
Ensure = 'Present'
Name = 'Web-WebServer'
}
WindowsFeature 'Web-Default-Doc'
{
Ensure = 'Present'
Name = 'Web-Default-Doc'
}
WindowsFeature 'Web-Static-Content'
{
Ensure = 'Present'
Name = 'Web-Static-Content'
}
WindowsFeature 'Web-Stat-Compression'
{
Ensure = 'Present'
Name = 'Web-Stat-Compression'
}
WindowsFeature 'Web-Filtering'
{
Ensure = 'Present'
Name = 'Web-Filtering'
}
WindowsFeature 'Web-Dyn-Compression'
{
Ensure = 'Present'
Name = 'Web-Dyn-Compression'
}
WindowsFeature 'Web-Windows-Auth'
{
Ensure = 'Present'
Name = 'Web-Windows-Auth'
}
WindowsFeature 'NET-Framework-45-ASPNET'
{
Ensure = 'Present'
Name = 'NET-Framework-45-ASPNET'
}
WindowsFeature 'Web-Net-Ext45'
{
Ensure = 'Present'
Name = 'Web-Net-Ext45'
}
WindowsFeature 'Web-ISAPI-Ext'
{
Ensure = 'Present'
Name = 'Web-ISAPI-Ext'
}
WindowsFeature 'Web-ISAPI-Filter'
{
Ensure = 'Present'
Name = 'Web-ISAPI-Filter'
}
WindowsFeature 'Web-Asp-Net45'
{
Ensure = 'Present'
Name = 'Web-Asp-Net45'
}
WindowsFeature 'Web-Metabase'
{
Ensure = 'Present'
Name = 'Web-Metabase'
}
WindowsFeature 'PowerShell'
{
Ensure = 'Present'
Name = 'PowerShell'
}
WindowsFeature 'PowerShell-V2'
{
Ensure = 'Present'
Name = 'PowerShell-V2'
}
WindowsFeature 'WAS-Process-Model'
{
Ensure = 'Present'
Name = 'WAS-Process-Model'
}
WindowsFeature 'WAS-NET-Environment'
{
Ensure = 'Present'
Name = 'WAS-NET-Environment'
}
WindowsFeature 'WAS-Config-APIs'
{
Ensure = 'Present'
Name = 'WAS-Config-APIs'
}
}
if(
($WindowsAzurePack2013AdminSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013AdminAuthenticationServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantAuthenticationSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
WindowsFeature 'Web-Mgmt-Console'
{
Ensure = 'Present'
Name = 'Web-Mgmt-Console'
}
}
if(
($WindowsAzurePack2013TenantSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
WindowsFeature 'Web-Basic-Auth'
{
Ensure = 'Present'
Name = 'Web-Basic-Auth'
}
}
# Install SQL Instances
if(
($WindowsAzurePack2013DatabaseServer -eq $Node.NodeName)
)
{
foreach($SQLServer in $Node.SQLServers)
{
$SQLInstanceName = $SQLServer.InstanceName
$SQLServiceaccount = $SQLServer.Serviceaccount
$Features = ''
if(
(
($WindowsAzurePack2013DatabaseServer -eq $Node.NodeName) -and
($WindowsAzurePack2013DatabaseInstance -eq $SQLInstanceName)
)
)
{
$Features += 'SQLENGINE'
}
$Features = $Features.Trim(',')
if($Features -ne '')
{
Group ($Node.NodeName + $SQLInstanceName)
{
Ensure = 'Present'
GroupName = 'MSSQL_Administrators'
Description = 'sysadmins in MSSQL'
MembersToInclude = $Node.SQLSysadmins
Credential = $Node.InstallerServiceAccount
}
User ($Node.NodeName + $SQLInstanceName)
{
DependsOn = ('[Group]' + $Node.NodeName + $SQLInstanceName)
UserName = $SQLServiceaccount.Username
Description = 'service account MSSQL'
Password = $SQLServiceaccount
Ensure = 'Present'
}
cSqlServerSetup ($Node.NodeName + $SQLInstanceName)
{
DependsOn = '[WindowsFeature]NETFrameworkCore'
SourcePath = $Node.SQLSourcePath
SourceFolder = $Node.SQLSourceFolder
SetupCredential = $Node.InstallerServiceAccount
InstanceName = $SQLInstanceName
Features = $Features
SQLSysAdminAccounts = $Node.AdminAccount
SQLSvcAccount = $SQLServiceaccount
SecurityMode = 'SQL'
SAPwd = $Node.SAPassword
UpdateSource = '.\MU'
InstallSharedDir = 'C:\Program Files\Microsoft SQL Server'
InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server'
InstanceDir = 'D:\Microsoft SQL Server'
InstallSQLDataDir = 'D:\Microsoft SQL Server'
SQLUserDBDir = 'D:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data'
SQLUserDBLogDir = 'D:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data'
SQLTempDBDir = 'D:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data'
SQLTempDBLogDir = 'D:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data'
SQLBackupDir = 'D:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Data'
ASDataDir = 'D:\Microsoft SQL Server\MSAS12.MSSQLSERVER\OLAP\Data'
ASLogDir = 'D:\Microsoft SQL Server\MSAS12.MSSQLSERVER\OLAP\Log'
ASBackupDir = 'D:\Microsoft SQL Server\MSAS12.MSSQLSERVER\OLAP\Backup'
ASTempDir = 'D:\Microsoft SQL Server\MSAS12.MSSQLSERVER\OLAP\Temp'
ASConfigDir = 'D:\Microsoft SQL Server\MSAS12.MSSQLSERVER\OLAP\Config'
}
cSqlServerFirewall ($Node.NodeName + $SQLInstanceName)
{
DependsOn = ('[cSqlServerSetup]' + $Node.NodeName + $SQLInstanceName)
SourcePath = $Node.SQLSourcePath
SourceFolder = $Node.SQLSourceFolder
InstanceName = $SQLInstanceName
Features = $Features
}
Service ($Node.NodeName + $SQLInstanceName)
{
DependsOn = ('[cSqlServerSetup]' + $Node.NodeName + $SQLInstanceName)
Name = $SQLServer.InstanceName
StartupType = 'Automatic'
State = 'Running'
Credential = $SQLServiceaccount
}
}
}
}
# Install ASP.NET Web Pages 2 and ASP.NET MVC 4
if(
($WindowsAzurePack2013AdminAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantPublicAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013SQLServerExtensionServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013MySQLExtensionServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013AdminSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013AdminAuthenticationServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantAuthenticationSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
# Install ASP.NET Web Pages 2
$ASPNETWebPages2 = '\Prerequisites\ASPNETWebPages2\AspNetWebPages2Setup.exe'
Package 'ASPNETWebPages2'
{
Ensure = 'Present'
Name = 'Microsoft ASP.NET Web Pages 2 Runtime'
ProductId = ''
Path = (Join-Path -Path $Node.WAPSourcePath -ChildPath $ASPNETWebPages2)
Arguments = '/q'
Credential = $Node.InstallerServiceAccount
}
# Install ASP.NET MVC 4
$ASPNETMVC4 = '\Prerequisites\ASPNETMVC4\AspNetMVC4Setup.exe'
Package 'ASPNETMVC4'
{
Ensure = 'Present'
Name = 'Microsoft ASP.NET MVC 4 Runtime'
ProductId = ''
Path = (Join-Path -Path $Node.WAPSourcePath -ChildPath $ASPNETMVC4)
Arguments = '/q'
Credential = $Node.InstallerServiceAccount
}
}
# Install MySQL Connector Net 6.5.4
if(
($WindowsAzurePack2013MySQLExtensionServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
# Install MySQL Connector Net 6.5.4
$MySQLConnectorNet654 = '\Prerequisites\MySQLConnectorNet654\mysql-connector-net-6.5.4.msi'
Package 'MySQLConnectorNet654'
{
Ensure = 'Present'
Name = 'MySQL Connector Net 6.5.4'
ProductId = ''
Path = (Join-Path -Path $Node.WAPSourcePath -ChildPath $MySQLConnectorNet654)
Arguments = 'ALLUSERS=2'
Credential = $Node.InstallerServiceAccount
}
}
# Install URL Rewrite 2
if(
($WindowsAzurePack2013AdminSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013AdminAuthenticationServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
}) -or
($WindowsAzurePack2013TenantAuthenticationSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
# Install URL Rewrite 2
$URLRewrite2 = '\Prerequisites\URLRewrite2\rewrite_amd64_en-US.msi'
Package 'URLRewrite2'
{
Ensure = 'Present'
Name = 'IIS URL Rewrite Module 2'
ProductId = ''
Path = (Join-Path -Path $Node.WAPSourcePath -ChildPath $URLRewrite2)
Arguments = 'ALLUSERS=2'
Credential = $Node.InstallerServiceAccount
}
}
# Install and initialize Azure Pack Admin API
if(
($WindowsAzurePack2013AdminAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
cAzurePackSetup 'AdminAPIInstall'
{
Role = 'Admin API'
Action = 'Install'
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
}
$DependsOn = @()
if(
($WindowsAzurePack2013AdminAPIServers[0] -eq $Node.NodeName)
)
{
# Wait for Azure Pack Database Server
if ($WindowsAzurePack2013AdminAPIServers[0] -eq $WindowsAzurePack2013DatabaseServer)
{
$DependsOn = @(('[cSqlServerFirewall]' + $WindowsAzurePack2013DatabaseServer + $WindowsAzurePack2013DatabaseInstance))
}
else
{
WaitForAll 'WAPDB'
{
NodeName = $WindowsAzurePack2013DatabaseServer
ResourceName = ('[cSqlServerFirewall]' + $WindowsAzurePack2013DatabaseServer + $WindowsAzurePack2013DatabaseInstance)
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
$DependsOn = @('[WaitForAll]WAPDB')
}
$DependsOn += @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]AdminAPIInstall'
)
cAzurePackSetup 'AdminAPIInitialize'
{
DependsOn = $DependsOn
Role = 'Admin API'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
if($Node.AzurePackAdminAPIFQDN)
{
if ($Node.AzurePackAdminAPIPort)
{
$AzurePackAdminAPIPort = $Node.AzurePackAdminAPIPort
}
else
{
$AzurePackAdminAPIPort = 30004
}
cAzurePackDatabaseSetting 'AntaresGeoMasterUri'
{
DependsOn = '[cAzurePackSetup]AdminAPIInitialize'
Namespace = 'AdminSite'
Name = 'Microsoft.Azure.Portal.Configuration.AppManagementConfiguration.AntaresGeoMasterUri'
Value = ('https://' + $Node.AzurePackAdminAPIFQDN + ':' + $AzurePackAdminAPIPort + '/services/webspaces/')
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
cAzurePackDatabaseSetting 'RdfeAdminManagementServiceUri'
{
DependsOn = '[cAzurePackSetup]AdminAPIInitialize'
Namespace = 'AdminSite'
Name = 'Microsoft.Azure.Portal.Configuration.AppManagementConfiguration.RdfeAdminManagementServiceUri'
Value = ('https://' + $Node.AzurePackAdminAPIFQDN + ':' + $AzurePackAdminAPIPort + '/')
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
cAzurePackDatabaseSetting 'RdfeAdminUri'
{
DependsOn = '[cAzurePackSetup]AdminAPIInitialize'
Namespace = 'AdminSite'
Name = 'Microsoft.Azure.Portal.Configuration.OnPremPortalConfiguration.RdfeAdminUri'
Value = ('https://' + $Node.AzurePackAdminAPIFQDN + ':' + $AzurePackAdminAPIPort + '/')
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
cAzurePackDatabaseSetting 'RdfeProvisioningUri'
{
DependsOn = '[cAzurePackSetup]AdminAPIInitialize'
Namespace = 'AdminSite'
Name = 'Microsoft.Azure.Portal.Configuration.OnPremPortalConfiguration.RdfeProvisioningUri'
Value = ('https://' + $Node.AzurePackAdminAPIFQDN + ':' + $AzurePackAdminAPIPort + '/')
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
}
}
else
{
WaitForAll 'AdminAPIInitialize'
{
NodeName = $WindowsAzurePack2013AdminAPIServers[0]
ResourceName = '[cAzurePackSetup]AdminAPIInitialize'
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
cAzurePackSetup 'AdminAPIInitialize'
{
DependsOn = @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]AdminAPIInstall',
'[WaitForAll]AdminAPIInitialize'
)
Role = 'Admin API'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
}
if($Node.AzurePackAdministratorsGroup)
{
cAzurePackAdmin 'WAPAdministrators'
{
DependsOn = '[cAzurePackSetup]AdminAPIInitialize'
Principal = $Node.AzurePackAdministratorsGroup
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
}
}
# Install and initialize Azure Pack Tenant API
if(
($WindowsAzurePack2013TenantAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
cAzurePackSetup 'TenantAPIInstall'
{
Role = 'Tenant API'
Action = 'Install'
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
}
$DependsOn = @()
if(
($WindowsAzurePack2013TenantAPIServers[0] -eq $Node.NodeName)
)
{
# Wait for Admin API
if ($WindowsAzurePack2013TenantAPIServers[0] -eq $WindowsAzurePack2013AdminAPIServers[0])
{
$DependsOn = @('[cAzurePackSetup]AdminAPIInitialize')
}
else
{
WaitForAll 'AdminAPI'
{
NodeName = $WindowsAzurePack2013AdminAPIServers[0]
ResourceName = ('[cAzurePackSetup]AdminAPIInitialize')
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
$DependsOn = @('[WaitForAll]AdminAPI')
}
$DependsOn += @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]TenantAPIInstall'
)
cAzurePackSetup 'TenantAPIInitialize'
{
DependsOn = $DependsOn
Role = 'Tenant API'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
if($Node.AzurePackTenantAPIFQDN)
{
if ($Node.AzurePackTenantAPIPort)
{
$AzurePackTenantAPIPort = $Node.AzurePackTenantAPIPort
}
else
{
$AzurePackTenantAPIPort = 30005
}
cAzurePackDatabaseSetting 'AdminSite-RdfeUnifiedManagementServiceUri'
{
DependsOn = '[cAzurePackSetup]TenantAPIInitialize'
Namespace = 'AdminSite'
Name = 'Microsoft.Azure.Portal.Configuration.AppManagementConfiguration.RdfeUnifiedManagementServiceUri'
Value = ('https://' + $Node.AzurePackTenantAPIFQDN + ':' + $AzurePackTenantAPIPort + '/')
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
cAzurePackDatabaseSetting 'TenantSite-RdfeUnifiedManagementServiceUri'
{
DependsOn = '[cAzurePackSetup]TenantAPIInitialize'
Namespace = 'TenantSite'
Name = 'Microsoft.Azure.Portal.Configuration.AppManagementConfiguration.RdfeUnifiedManagementServiceUri'
Value = ('https://' + $Node.AzurePackTenantAPIFQDN + ':' + $AzurePackTenantAPIPort + '/')
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
}
}
else
{
WaitForAll 'TenantAPIInitialize'
{
NodeName = $WindowsAzurePack2013TenantAPIServers[0]
ResourceName = '[cAzurePackSetup]TenantAPIInitialize'
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
cAzurePackSetup 'TenantAPIInitialize'
{
DependsOn = @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]TenantAPIInstall',
'[WaitForAll]TenantAPIInitialize'
)
Role = 'Tenant API'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
}
}
# Install and initialize Azure Pack Tenant Public API
if(
($WindowsAzurePack2013TenantPublicAPIServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
cAzurePackSetup 'TenantPublicAPIInstall'
{
Role = 'Tenant Public API'
Action = 'Install'
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
}
$DependsOn = @()
if(
($WindowsAzurePack2013TenantPublicAPIServers[0] -eq $Node.NodeName)
)
{
# Wait for Tenant API
if ($WindowsAzurePack2013TenantPublicAPIServers[0] -eq $WindowsAzurePack2013TenantAPIServers[0])
{
$DependsOn = @('[cAzurePackSetup]TenantAPIInitialize')
}
else
{
WaitForAll 'TenantAPI'
{
NodeName = $WindowsAzurePack2013TenantAPIServers[0]
ResourceName = ('[cAzurePackSetup]TenantAPIInitialize')
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
$DependsOn = @('[WaitForAll]TenantAPI')
}
$DependsOn += @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]TenantPublicAPIInstall'
)
cAzurePackSetup 'TenantPublicAPIInitialize'
{
DependsOn = $DependsOn
Role = 'Tenant Public API'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
if($Node.AzurePackTenantPublicAPIFQDN)
{
if ($Node.AzurePackTenantPublicAPIPort)
{
$AzurePackTenantPublicAPIPort = $Node.AzurePackTenantPublicAPIPort
}
else
{
$AzurePackTenantPublicAPIPort = 30006
}
cAzurePackDatabaseSetting 'PublicRdfeProvisioningUri'
{
DependsOn = '[cAzurePackSetup]TenantPublicAPIInitialize'
Namespace = 'TenantSite'
Name = 'Microsoft.WindowsAzure.Server.Configuration.TenantPortalConfiguration.PublicRdfeProvisioningUri'
Value = ('https://' + $Node.AzurePackTenantPublicAPIFQDN + ':' + $AzurePackTenantPublicAPIPort + '/')
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
}
}
else
{
WaitForAll 'TenantPublicAPIInitialize'
{
NodeName = $WindowsAzurePack2013TenantPublicAPIServers[0]
ResourceName = '[cAzurePackSetup]TenantPublicAPIInitialize'
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
cAzurePackSetup 'TenantPublicAPIInitialize'
{
DependsOn = @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]TenantPublicAPIInstall',
'[WaitForAll]TenantPublicAPIInitialize'
)
Role = 'Tenant Public API'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
}
}
# Install and initialize Azure Pack SQL Server Extension
if(
($WindowsAzurePack2013SQLServerExtensionServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
cAzurePackSetup 'SQLServerExtensionInstall'
{
Role = 'SQL Server Extension'
Action = 'Install'
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
}
$DependsOn = @()
if(
($WindowsAzurePack2013SQLServerExtensionServers[0] -eq $Node.NodeName)
)
{
# Wait for Admin API
if ($WindowsAzurePack2013SQLServerExtensionServers[0] -eq $WindowsAzurePack2013AdminAPIServers[0])
{
$DependsOn = @('[cAzurePackSetup]AdminAPIInitialize')
}
else
{
WaitForAll 'AdminAPI'
{
NodeName = $WindowsAzurePack2013AdminAPIServers[0]
ResourceName = ('[cAzurePackSetup]AdminAPIInitialize')
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
$DependsOn = @('[WaitForAll]AdminAPI')
}
$DependsOn += @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]SQLServerExtensionInstall'
)
cAzurePackSetup 'SQLServerExtensionInitialize'
{
DependsOn = $DependsOn
Role = 'SQL Server Extension'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
}
else
{
WaitForAll 'SQLServerExtensionInitialize'
{
NodeName = $WindowsAzurePack2013SQLServerExtensionServers[0]
ResourceName = '[cAzurePackSetup]SQLServerExtensionInitialize'
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
cAzurePackSetup 'SQLServerExtensionInitialize'
{
DependsOn = @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]SQLServerExtensionInstall',
'[WaitForAll]SQLServerExtensionInitialize'
)
Role = 'SQL Server Extension'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
}
}
# Install and initialize Azure Pack MySQL Extension
if(
($WindowsAzurePack2013MySQLExtensionServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
cAzurePackSetup 'MySQLExtensionInstall'
{
Role = 'MySQL Extension'
Action = 'Install'
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
}
$DependsOn = @()
if(
($WindowsAzurePack2013MySQLExtensionServers[0] -eq $Node.NodeName)
)
{
# Wait for Admin API
if ($WindowsAzurePack2013MySQLExtensionServers[0] -eq $WindowsAzurePack2013AdminAPIServers[0])
{
$DependsOn = @('[cAzurePackSetup]AdminAPIInitialize')
}
else
{
WaitForAll 'AdminAPI'
{
NodeName = $WindowsAzurePack2013AdminAPIServers[0]
ResourceName = ('[cAzurePackSetup]AdminAPIInitialize')
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
$DependsOn = @('[WaitForAll]AdminAPI')
}
$DependsOn += @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]MySQLExtensionInstall'
)
cAzurePackSetup 'MySQLExtensionInitialize'
{
DependsOn = $DependsOn
Role = 'MySQL Extension'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
}
else
{
WaitForAll 'MySQLExtensionInitialize'
{
NodeName = $WindowsAzurePack2013MySQLExtensionServers[0]
ResourceName = '[cAzurePackSetup]MySQLExtensionInitialize'
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
cAzurePackSetup 'MySQLExtensionInitialize'
{
DependsOn = @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]MySQLExtensionInstall',
'[WaitForAll]MySQLExtensionInitialize'
)
Role = 'MySQL Extension'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
}
}
# Install and initialize Azure Pack Admin Site
if(
($WindowsAzurePack2013AdminSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
cAzurePackSetup 'AdminSiteInstall'
{
Role = 'Admin Site'
Action = 'Install'
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
}
$DependsOn = @()
if(
($WindowsAzurePack2013AdminSiteServers[0] -eq $Node.NodeName)
)
{
# Wait for Admin API
if ($WindowsAzurePack2013AdminSiteServers[0] -eq $WindowsAzurePack2013AdminAPIServers[0])
{
$DependsOn = @('[cAzurePackSetup]AdminAPIInitialize')
}
else
{
WaitForAll 'AdminAPI'
{
NodeName = $WindowsAzurePack2013AdminAPIServers[0]
ResourceName = ('[cAzurePackSetup]AdminAPIInitialize')
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
$DependsOn = @('[WaitForAll]AdminAPI')
}
$DependsOn += @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]AdminSiteInstall'
)
cAzurePackSetup 'AdminSiteInitialize'
{
DependsOn = $DependsOn
Role = 'Admin Site'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
if($Node.AzurePackAdminSiteFQDN)
{
cManageCertificates 'AdminSite'
{
DependsOn = '[cAzurePackSetup]AdminSiteInitialize'
Thumbprint = $Node.WAPCertificateThumbprint
Location = $Node.WAPCertificatelocation
Ensure = 'Present'
Password = $Node.WAPCertificatepassword
Store = 'My'
StoreType = 'LocalMachine'
Reboot = $false
PsDscRunAsCredential = $Node.InstallerServiceAccount
}
cWebsite 'AdminSite'
{
DependsOn = '[cAzurePackSetup]AdminSiteInitialize'
Name = 'MgmtSvc-AdminSite'
Ensure = 'Present'
State = 'Started'
PhysicalPath = 'C:\inetpub\MgmtSvc-AdminSite'
BindingInfo = cWebBindingInformation
{
Protocol = 'HTTPS'
Port = $Node.AzurePackAdminSitePort
HostName = $Node.AzurePackAdminSiteFQDN
CertificateThumbprint = $Node.WAPCertificateThumbprint
CertificateStoreName = 'My'
}
}
cAzurePackFQDN 'AdminSite'
{
DependsOn = '[cAzurePackSetup]AdminSiteInitialize'
Namespace = 'AdminSite'
FullyQualifiedDomainName = $Node.AzurePackAdminSiteFQDN
Port = $Node.AzurePackAdminSitePort
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
cAzurePackIdentityProvider 'AdminSite'
{
DependsOn = '[cAzurePackSetup]AdminSiteInitialize'
Target = 'Windows'
FullyQualifiedDomainName = $Node.AzurePackAdminSiteFQDN
Port = $Node.AzurePackAdminSitePort
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
}
}
else
{
WaitForAll 'AdminSiteInitialize'
{
NodeName = $WindowsAzurePack2013AdminSiteServers[0]
ResourceName = '[cAzurePackSetup]AdminSiteInitialize'
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
cAzurePackSetup 'AdminSiteInitialize'
{
DependsOn = @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]AdminSiteInstall',
'[WaitForAll]AdminSiteInitialize'
)
Role = 'Admin Site'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
}
}
# Install and initialize Azure Pack Admin Authentication Site
if(
($WindowsAzurePack2013AdminAuthenticationSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
cAzurePackSetup 'AdminAuthenticationSiteInstall'
{
Role = 'Admin Authentication Site'
Action = 'Install'
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
}
$DependsOn = @()
if(
($WindowsAzurePack2013AdminAuthenticationSiteServers[0] -eq $Node.NodeName)
)
{
# Wait for Admin API
if ($WindowsAzurePack2013AdminAuthenticationSiteServers[0] -eq $WindowsAzurePack2013AdminAPIServers[0])
{
$DependsOn = @('[cAzurePackSetup]AdminAPIInitialize')
}
else
{
if ($WindowsAzurePack2013AdminAuthenticationSiteServers[0] -eq $WindowsAzurePack2013AdminSiteServers[0])
{
$DependsOn = @('[cAzurePackSetup]AdminSiteInitialize')
}
else
{
WaitForAll 'AdminAPI'
{
NodeName = $WindowsAzurePack2013AdminAPIServers[0]
ResourceName = ('[cAzurePackSetup]AdminAPIInitialize')
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
$DependsOn = @('[WaitForAll]AdminAPI')
}
}
$DependsOn += @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]AdminAuthenticationSiteInstall'
)
cAzurePackSetup 'AdminAuthenticationSiteInitialize'
{
DependsOn = $DependsOn
Role = 'Admin Authentication Site'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
PsDscRunAsCredential = $Node.InstallerServiceAccount
}
if($Node.AzurePackWindowsAuthSiteFQDN)
{
if ($WindowsAzurePack2013AdminSiteServers[0] -ne $WindowsAzurePack2013AdminAuthenticationSiteServers[0])
{
cManageCertificates 'AdminAuthenticationSite'
{
DependsOn = '[cAzurePackSetup]AdminAuthenticationSiteInitialize'
Thumbprint = $Node.WAPCertificateThumbprint
Location = $Node.WAPCertificatelocation
Ensure = 'Present'
Password = $Node.WAPCertificatepassword
Store = 'My'
StoreType = 'LocalMachine'
Reboot = $false
PsDscRunAsCredential = $Node.InstallerServiceAccount
}
}
cWebsite 'AdminAuthenticationSite'
{
DependsOn = '[cAzurePackSetup]AdminAuthenticationSiteInitialize'
Name = 'MgmtSvc-WindowsAuthSite'
Ensure = 'Present'
State = 'Started'
PhysicalPath = 'C:\inetpub\MgmtSvc-WindowsAuthSite'
BindingInfo = cWebBindingInformation
{
Protocol = 'HTTPS'
Port = $Node.AzurePackWindowsAuthSitePort
HostName = $Node.AzurePackWindowsAuthSiteFQDN
CertificateThumbprint = $Node.WAPCertificateThumbprint
CertificateStoreName = 'My'
}
}
cAzurePackFQDN 'AdminAuthenticationSite'
{
DependsOn = '[cAzurePackSetup]AdminAuthenticationSiteInitialize'
Namespace = 'WindowsAuthSite'
Port = $Node.AzurePackWindowsAuthSitePort
FullyQualifiedDomainName = $Node.AzurePackWindowsAuthSiteFQDN
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
cAzurePackRelyingParty 'AdminAuthenticationSite'
{
DependsOn = '[cAzurePackSetup]AdminAuthenticationSiteInitialize'
Target = 'Admin'
FullyQualifiedDomainName = $Node.AzurePackWindowsAuthSiteFQDN
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
}
}
else
{
WaitForAll 'AdminAuthenticationSiteInitialize'
{
NodeName = $WindowsAzurePack2013AdminAuthenticationSiteServers[0]
ResourceName = '[cAzurePackSetup]AdminAuthenticationSiteInitialize'
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
cAzurePackSetup 'AdminAuthenticationSiteInitialize'
{
DependsOn = @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]AdminAuthenticationSiteInstall',
'[WaitForAll]AdminAuthenticationSiteInitialize'
)
Role = 'Admin Authentication Site'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
PsDscRunAsCredential = $Node.InstallerServiceAccount
}
}
}
# Install and initialize Azure Pack Tenant Site
if(
($WindowsAzurePack2013TenantSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
cAzurePackSetup 'TenantSiteInstall'
{
Role = 'Tenant Site'
Action = 'Install'
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
}
$DependsOn = @()
if(
($WindowsAzurePack2013TenantSiteServers[0] -eq $Node.NodeName)
)
{
# Wait for Tenant Public API
if ($WindowsAzurePack2013TenantSiteServers[0] -eq $WindowsAzurePack2013TenantPublicAPIServers[0])
{
$DependsOn = @('[cAzurePackSetup]TenantPublicAPIInitialize')
}
else
{
WaitForAll 'AdminAPI'
{
NodeName = $WindowsAzurePack2013TenantPublicAPIServers[0]
ResourceName = ('[cAzurePackSetup]TenantPublicAPIInitialize')
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
$DependsOn = @('[WaitForAll]AdminAPI')
}
$DependsOn += @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]TenantSiteInstall'
)
cAzurePackSetup 'TenantSiteInitialize'
{
DependsOn = $DependsOn
Role = 'Tenant Site'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
if($Node.AzurePackTenantSiteFQDN)
{
cManageCertificates 'TenantSite'
{
DependsOn = '[cAzurePackSetup]TenantSiteInitialize'
Thumbprint = $Node.WAPCertificateThumbprint
Location = $Node.WAPCertificatelocation
Ensure = 'Present'
Password = $Node.WAPCertificatepassword
Store = 'My'
StoreType = 'LocalMachine'
Reboot = $false
PsDscRunAsCredential = $Node.InstallerServiceAccount
}
cWebsite 'TenantSite'
{
DependsOn = '[cAzurePackSetup]TenantSiteInitialize'
Name = 'MgmtSvc-TenantSite'
Ensure = 'Present'
State = 'Started'
PhysicalPath = 'C:\inetpub\MgmtSvc-TenantSite'
BindingInfo = cWebBindingInformation
{
Protocol = 'HTTPS'
Port = $Node.AzurePackTenantSitePort
HostName = $Node.AzurePackTenantSiteFQDN
CertificateThumbprint = $Node.WAPCertificateThumbprint
CertificateStoreName = 'My'
}
}
cAzurePackFQDN 'TenantSite'
{
DependsOn = '[cAzurePackSetup]TenantSiteInitialize'
Namespace = 'TenantSite'
FullyQualifiedDomainName = $Node.AzurePackTenantSiteFQDN
Port = $Node.AzurePackTenantSitePort
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
cAzurePackIdentityProvider 'TenantSite'
{
DependsOn = '[cAzurePackSetup]TenantSiteInitialize'
Target = 'Membership'
FullyQualifiedDomainName = $Node.AzurePackTenantSiteFQDN
Port = $Node.AzurePackTenantSitePort
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
}
}
else
{
WaitForAll 'TenantSiteInitialize'
{
NodeName = $WindowsAzurePack2013TenantSiteServers[0]
ResourceName = '[cAzurePackSetup]TenantSiteInitialize'
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
cAzurePackSetup 'TenantSiteInitialize'
{
DependsOn = @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]TenantSiteInstall',
'[WaitForAll]TenantSiteInitialize'
)
Role = 'Tenant Site'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
}
}
# Install and initialize Azure Pack Tenant Authentication Site
if(
($WindowsAzurePack2013TenantAuthenticationSiteServers | Where-Object -FilterScript {
$_ -eq $Node.NodeName
})
)
{
cAzurePackSetup 'TenantAuthenticationSiteInstall'
{
Role = 'Tenant Authentication Site'
Action = 'Install'
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
}
$DependsOn = @()
if(
($WindowsAzurePack2013TenantAuthenticationSiteServers[0] -eq $Node.NodeName)
)
{
# Wait for Tenant Public API
if ($WindowsAzurePack2013TenantAuthenticationSiteServers[0] -eq $WindowsAzurePack2013TenantPublicAPIServers[0])
{
$DependsOn = @('[cAzurePackSetup]TenantPublicAPIInitialize')
}
else
{
WaitForAll 'AdminAPI'
{
NodeName = $WindowsAzurePack2013TenantPublicAPIServers[0]
ResourceName = ('[cAzurePackSetup]TenantPublicAPIInitialize')
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
$DependsOn = @('[WaitForAll]AdminAPI')
}
$DependsOn += @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]TenantAuthenticationSiteInstall'
)
cAzurePackSetup 'TenantAuthenticationSiteInitialize'
{
DependsOn = $DependsOn
Role = 'Tenant Authentication Site'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
if($Node.AzurePackAuthSiteFQDN)
{
if ($WindowsAzurePack2013TenantAuthenticationSiteServers[0] -ne $WindowsAzurePack2013TenantSiteServers[0])
{
cManageCertificates 'TenantAuthenticationSite'
{
DependsOn = '[cAzurePackSetup]TenantAuthenticationSiteInitialize'
Thumbprint = $Node.WAPCertificateThumbprint
Location = $Node.WAPCertificatelocation
Ensure = 'Present'
Password = $Node.WAPCertificatepassword
Store = 'My'
StoreType = 'LocalMachine'
Reboot = $false
PsDscRunAsCredential = $Node.InstallerServiceAccount
}
}
cWebsite 'TenantAuthenticationSite'
{
DependsOn = '[cAzurePackSetup]TenantAuthenticationSiteInitialize'
Name = 'MgmtSvc-AuthSite'
Ensure = 'Present'
State = 'Started'
PhysicalPath = 'C:\inetpub\MgmtSvc-AuthSite'
BindingInfo = cWebBindingInformation
{
Protocol = 'HTTPS'
Port = $Node.AzurePackAuthSitePort
HostName = $Node.AzurePackAuthSiteFQDN
CertificateThumbprint = $Node.WAPCertificateThumbprint
CertificateStoreName = 'My'
}
}
cAzurePackFQDN 'TenantAuthenticationSite'
{
DependsOn = '[cAzurePackSetup]TenantAuthenticationSiteInitialize'
Namespace = 'AuthSite'
Port = $Node.AzurePackAuthSitePort
FullyQualifiedDomainName = $Node.AzurePackAuthSiteFQDN
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
cAzurePackRelyingParty 'TenantAuthenticationSite'
{
DependsOn = '[cAzurePackSetup]TenantAuthenticationSiteInitialize'
Target = 'Tenant'
FullyQualifiedDomainName = $Node.AzurePackAuthSiteFQDN
AzurePackAdminCredential = $Node.InstallerServiceAccount
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
dbUser = $Node.SAPassword
}
}
}
else
{
WaitForAll 'TenantAuthenticationSiteInitialize'
{
NodeName = $WindowsAzurePack2013TenantAuthenticationSiteServers[0]
ResourceName = '[cAzurePackSetup]TenantAuthenticationSiteInitialize'
PsDscRunAsCredential = $Node.InstallerServiceAccount
RetryCount = 720
RetryIntervalSec = 20
}
cAzurePackSetup 'TenantAuthenticationSiteInitialize'
{
DependsOn = @(
'[xCredSSP]Client',
'[xCredSSP]Server',
'[cAzurePackSetup]TenantAuthenticationSiteInstall',
'[WaitForAll]TenantAuthenticationSiteInitialize'
)
Role = 'Tenant Authentication Site'
Action = 'Initialize'
dbUser = $Node.SAPassword
SourcePath = $Node.WAPSourcePath
SourceFolder = 'Installer'
SetupCredential = $Node.InstallerServiceAccount
Passphrase = $Node.WAPackPassphrase
SQLServer = $WindowsAzurePack2013DatabaseServer
SQLInstance = $WindowsAzurePack2013DatabaseInstance
}
}
}
}
}
$ConfigurationData = @{
AllNodes = @(
@{
NodeName = '*'
PSDscAllowDomainUser = $true
PSDSCAllowPlaintextpassword = $true
SQLSourcePath = '\\labfileshare\Data'
SQLSourceFolder = 'SQLServer\2014'
SQLSysadmins = @('Administrator', 'LAB\MSSQL_Administrators')
WAPSourcePath = '\\labfileshare\Data\WAP'
InstallerServiceAccount = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ('LAB\Administrator', $InstallerPassword)
AdminAccount = '.\MSSQL_Administrators'
SAPassword = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ('SA', $ServerAdminPassword)
AzurePackAdministratorsGroup = 'LAB\WAP_Administrators'
WAPackPassphrase = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ('notrequired', $WAPPassphrase)
AzurePackTenantSiteFQDN = 'portal.LAB.local'
AzurePackAdminSiteFQDN = 'admin.LAB.local'
AzurePackAuthSiteFQDN = 'auth.LAB.local'
AzurePackWindowsAuthSiteFQDN = 'adminauth.LAB.local'
AzurePackTenantAPIFQDN = 'wapapi.LAB.local'
AzurePackAdminAPIFQDN = 'wapadminapi.LAB.local'
AzurePackTenantPublicAPIFQDN = 'pubapi.LAB.local'
AzurePackSQLServerExtensionFQDN = 'wapsql.LAB.local'
AzurePackMySQLExtensionFQDN = 'wapmysql.LAB.local'
AzurePackAdminAPIPort = 30004
AzurePackTenantAPIPort = 30005
AzurePackTenantPublicAPIPort = 30006
AzurePackMarketplacePort = 30018
AzurePackMonitoringPort = 30020
AzurePackUsageServicePort = 30022
AzurePackSQLServerExtensionPort = 30010
AzurePackMySQLExtensionPort = 30012
AzurePackAuthSitePort = 30071
AzurePackWindowsAuthSitePort = 30072
AzurePackTenantSitePort = 443
AzurePackAdminSitePort = 443
WAPCertificatelocation = '\\labfileshare\Data\WAP\Prerequisites\WAP.pfx'
WAPCertificateThumbprint = '1a10106c6d53119788105e45f81305c382e44d34'
WAPCertificatepassword = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ('LAB\Administrator', $InstallerPassword)
}
@{
NodeName = 'Databaseserver'
NodeGuid = 'ce553425-8ff2-4dd0-94c8-80427696b8fa'
Roles = @(
'Windows Azure Pack 2013 Database Server'
)
SQLServers = @(
@{
Roles = @('Windows Azure Pack 2013 Database Server')
InstanceName = 'MSSQLSERVER'
Serviceaccount = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ('SRV_MSSQL', (ConvertTo-SecureString -String '$erv1ceP$$wd!' -AsPlainText -Force))
}
)
}
@{
NodeName = 'TenantAPI'
NodeGuid = 'e047c414-2bfc-48d8-bf15-dc84575f9315'
Roles = @(
'Windows Azure Pack 2013 Tenant API Server'
)
}
@{
NodeName = 'AdminAPI_SQLext_MYSQLext'
NodeGuid = 'd7f7f1f3-8910-4b8e-bb5a-0c677d0aac0e'
Roles = @(
'Windows Azure Pack 2013 Admin API Server',
'Windows Azure Pack 2013 SQL Server Extension Server',
'Windows Azure Pack 2013 MySQL Extension Server'
)
}
@{
NodeName = 'TenantSite_TenantPublicAPI_TenantAuthenticationSite'
NodeGuid = 'a3fb549d-873a-411c-a71a-859d9c9ae4cb'
Roles = @(
'Windows Azure Pack 2013 Tenant Public API Server',
'Windows Azure Pack 2013 Tenant Site Server',
'Windows Azure Pack 2013 Tenant Authentication Site Server'
)
}
@{
NodeName = 'AdminSite_AdminAuthenticationSite'
NodeGuid = '434e50c2-f289-48b2-b92d-20725831f4ed'
Roles = @(
'Windows Azure Pack 2013 Admin Site Server',
'Windows Azure Pack 2013 Admin Authentication Site Server'
)
}
)
}
Example_WindowsAzurePack -ConfigurationData $ConfigurationData -OutputPath 'C:\DSC\Staging\Example_WindowsAzurePack'
|
PowerShellCorpus/PowerShellGallery/ArkanePsh/0.1/InitVariables.ps1
|
InitVariables.ps1
|
#
# InitVariables.ps1
#
# Internal helper functions
function Set-ArkaneVariable ($name, $value)
{
Set-Variable $name $value -Scope Global -Option AllScope,ReadOnly -Description "ArkanePsh module variable." -Force
}
# Set up relevant variables
Set-ArkaneVariable myDocuments ([System.Environment]::GetFolderPath(5))
Set-ArkaneVariable executableExtensions (".exe",".ps1",".cmd",".py")
Set-ArkaneVariable archiveExtensions (".7z",".zip",".gz",".bz2",".rar",".tar",".z")
Set-ArkaneVariable windowsIdentity ([System.Security.Principal.WindowsIdentity]::GetCurrent())
Set-ArkaneVariable windowsPrincipal (new-object System.Security.Principal.WindowsPrincipal $windowsIdentity)
Set-ArkaneVariable isAdmin ($windowsPrincipal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
# This next is intended to be overriden in profile.
Set-Variable workingFolder "C:\Working" -Scope Global -Option AllScope -Description "(Overridable) ArkanePsh module variable." -Force
# Delete internal helper functions
remove-item function:Set-ArkaneVariable
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/Save-EWSAttachment.ps1
|
Save-EWSAttachment.ps1
|
function Save-EWSAttachment {
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'Low'
)]
param (
[string]$Path = '.',
[Parameter(
ValueFromPipelineByPropertyName,
ValueFromPipeline
)]
[Microsoft.Exchange.WebServices.Data.FileAttachment[]]$Attachment,
[Parameter(
ValueFromPipelineByPropertyName
)]
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $script:exchangeService
)
process {
if (-not $Service) {
return
}
foreach ($singleAttachment in $Attachment) {
$fullPath = Join-Path -Path $Path -ChildPath $singleAttachment.Name
if ($PSCmdlet.ShouldProcess(
$singleAttachment.Name,
"Save to $Path"
)) {
$singleAttachment.Load(
$fullPath
)
}
}
}
end {
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
}
}
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/Move-EWSFolder.ps1
|
Move-EWSFolder.ps1
|
function Move-EWSFolder {
[CmdletBinding(
ConfirmImpact = 'Medium',
SupportsShouldProcess
)]
param (
[Parameter(
Mandatory
)]
[ValidateScript({
$root, $rest = $_ -split '\\|/|:|\|'
try {
[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]$root
$true
} catch {
throw "Root folder must belong to collection of WellKnownFolderName: $_"
}
})]
[string]$DestinationPath,
[Parameter(
ValueFromPipeline,
Mandatory
)]
[Microsoft.Exchange.WebServices.Data.Folder]$Folder,
[Parameter(
ValueFromPipelineByPropertyName
)]
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $Script:exchangeService
)
begin {
$Mailbox = $Connections[$Service]
$name = [Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName
$rootName, $remaingPath = $DestinationPath -split '\\|/|:|\|'
try {
$rootId = New-Object Microsoft.Exchange.WebServices.Data.FolderId $rootName, $Mailbox
} catch {
throw "Unexpected error occured: $_"
}
$root = [Microsoft.Exchange.WebServices.Data.Folder]::Bind(
$Service,
$rootId
)
foreach ($pathItem in $remaingPath) {
$filter = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo -ArgumentList @(
$name,
$pathItem
)
try {
$new = $root.FindFolders($filter,1).Folders[0]
if ($new) {
$root = $new
}
} catch {
Write-Error "Could not find sub-folder: $pathItem"
$root
return
}
}
$destination = $root
}
process {
if (-not $Service) {
return
}
if ($PSCmdlet.ShouldProcess(
$Folder.DisplayName,
"Move to $DestinationPath"
)) {
$Folder.Move($destination.Id)
}
}
end {
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
return
}
}
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/New-EWSMessage.ps1
|
New-EWSMessage.ps1
|
function New-EWSMessage {
[OutputType('Microsoft.Exchange.WebServices.Data.EmailMessage')]
[CmdletBinding(
DefaultParameterSetName = 'inline'
)]
param (
[Parameter(
Mandatory
)]
[string[]]$To,
[string[]]$Cc,
[string[]]$Bcc,
[Parameter(
Mandatory
)]
[string]$Subject,
[Parameter(
Mandatory,
ParameterSetName = 'inline'
)]
[string]$Body,
[Microsoft.Exchange.WebServices.Data.BodyType]$BodyType = 'Text',
[string[]]$Attachment,
[Parameter(
ValueFromPipeline,
Mandatory,
ParameterSetName = 'pipe'
)]
$InputObject,
[Parameter(
ParameterSetName = 'pipe'
)]
[switch]$IsHtml,
[Parameter(
ValueFromPipelineByPropertyName
)]
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $script:exchangeService
)
begin {
$data = New-Object Collections.ArrayList
}
process {
if (-not $Service) {
return
}
if ($InputObject) {
$null = $data.Add($InputObject)
}
}
end {
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
return
}
if ($data.Count) {
if (! $IsHtml -and $BodyType -eq 'HTML') {
$body = $data | ConvertTo-Html | Out-String
} else {
$body = $data | Out-String
}
}
$message = New-Object Microsoft.Exchange.WebServices.Data.EmailMessage $Service
$message.Subject = $Subject
$message.Body = $body
$message.Body.BodyType = $BodyType
foreach ($file in $Attachment) {
$null = $message.Attachments.AddFileAttachment($file)
}
foreach ($recipient in $To) {
$null = $message.ToRecipients.Add(
$recipient
)
}
foreach ($recipient in $Cc) {
$null = $message.CcRecipients.Add(
$recipient
)
}
foreach ($recipient in $Bcc) {
$null = $message.BccRecipients.Add(
$recipient
)
}
$message.SendAndSaveCopy()
$message
}
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/New-EWSContact.ps1
|
New-EWSContact.ps1
|
function New-EWSContact {
[OutputType('Microsoft.Exchange.WebServices.Data.Contact')]
param (
[string]$GivenName,
[string]$Surname,
[string]$MiddleName,
[string]$Company,
[ValidateScript({
try {
foreach ($key in $_.Keys) {
[Microsoft.Exchange.WebServices.Data.PhoneNumberKey]$key
}
$true
} catch {
throw "Error: $key - $_"
}
})]
[hashtable]$Phone,
[ValidateScript({
foreach ($hash in $_) {
foreach ($key in $hash.Keys) {
if ('DisplayName','email' -notcontains $key) {
throw "Wrong key in e-mail hashtable: $key"
}
}
}
$true
})]
[hashtable[]]$Email,
[ValidateScript({
try {
foreach ($key in $_.Keys) {
[Microsoft.Exchange.WebServices.Data.PhysicalAddressKey]$key
}
} catch {
throw "Error: $key - $_"
}
foreach ($hash in $_.Values) {
foreach ($key in $hash.Keys) {
if ('City','CountryOrRegion','PostalCode','State','Street' -notcontains $key) {
throw "Wrong key in physical address hashtable: $key"
}
}
}
$true
})]
[hashtable]$PhysicalAddress,
[Parameter(
ValueFromPipelineByPropertyName
)]
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $script:ExchangeService
)
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
return
}
$contact = New-Object Microsoft.Exchange.WebServices.Data.Contact $Service -Property @{
GivenName = $GivenName
MiddleName = $MiddleName
Surname = $Surname
CompanyName = $Company
FileAsMapping = [Microsoft.Exchange.WebServices.Data.FileAsMapping]::SurnameCommaGivenName
}
foreach ($key in $Phone.Keys) {
$Contact.PhoneNumbers[$key] = $Phone.$key
}
$index = 1
foreach ($hash in $Email) {
if ($index -le 3) {
if ($emailAddress = $hash.email) {
if (! ($displayName = $hash.DisplayName)) {
$displayName = $hash.email
}
$contact.EmailAddresses["EmailAddress$index"] =
New-Object Microsoft.Exchange.WebServices.Data.EmailAddress -ArgumentList @(
$displayName
$emailAddress
)
$index++
}
}
}
foreach ($key in $PhysicalAddress.Keys) {
$contact.PhysicalAddresses[$key] =
New-Object Microsoft.Exchange.WebServices.Data.PhysicalAddressEntry -Property @{
City = $PhysicalAddress[$key].City
CountryOrRegion = $PhysicalAddress[$key].CountryOrRegion
PostalCode = $PhysicalAddress[$key].PostalCode
State = $PhysicalAddress[$key].State
Street = $PhysicalAddress[$key].Street
}
}
$contact.Save()
$contact
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/New-EWSFolder.ps1
|
New-EWSFolder.ps1
|
function New-EWSFolder {
[OutputType('Microsoft.Exchange.WebServices.Data.Folder')]
[CmdletBinding(
DefaultParameterSetName = 'byName'
)]
param (
[Parameter(
Mandatory,
ValueFromPipelineByPropertyName
)]
[string]$DisplayName,
[Parameter(
ValueFromPipelineByPropertyName
)]
[ValidateSet(
'Calendar',
'Contacts',
'Tasks',
'Mail'
)]
[string]$FolderType = 'Mail',
[Parameter(
ParameterSetName = 'byId',
ValueFromPipelineByPropertyName,
Mandatory
)]
[Alias('Id')]
[Microsoft.Exchange.WebServices.Data.FolderId]$ParentId,
[Parameter(
ParameterSetName = 'byName',
Mandatory
)]
[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]$ParentName,
[Parameter(
ValueFromPipelineByPropertyName
)]
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $Script:exchangeService,
[Microsoft.Exchange.WebServices.Data.Mailbox]$Mailbox
)
begin {
$type = 'Microsoft.Exchange.WebServices.Data.{0}Folder' -f "$(
if ($FolderType -ne 'Mail') {
$FolderType
}
)"
}
process {
if (-not $Service) {
return
}
if ($PSCmdlet.ParameterSetName -eq 'byName') {
if (-not $PSBoundParameters.ContainsKey('Mailbox')) {
if (-not ($Mailbox = $Connections[$Service])) {
$Mailbox = $Script:Mailbox
}
}
$folder = New-Object Microsoft.Exchange.WebServices.Data.FolderId $ParentName, $Mailbox
$parentId = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($Service, $ParentName).Id
}
$newFolder = New-Object $Type $Service
if ($FolderType -eq 'Mail') {
$newFolder.FolderClass = 'IPF.Note'
}
$newFolder.DisplayName = $DisplayName
$newFolder.Save($parentId)
$name = [Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName
$root = [Microsoft.Exchange.WebServices.Data.Folder]::Bind(
$Service,
$parentId
)
$filter = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo -ArgumentList @(
$name,
$DisplayName
)
try {
$root.FindFolders($filter,1).Folders[0]
} catch {}
}
end {
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
return
}
}
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/Get-EWSAttachment.ps1
|
Get-EWSAttachment.ps1
|
function Get-EWSAttachment {
[OutputType('Microsoft.Exchange.WebServices.Data.FileAttachment')]
[CmdletBinding()]
param (
[Parameter(
ValueFromPipeline
)]
[Microsoft.Exchange.WebServices.Data.Item[]]$Item,
[Parameter(
ValueFromPipelineByPropertyName
)]
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $script:exchangeService
)
process {
if (-not $Service) {
return
}
$null = $Service.LoadPropertiesForItems(
$Item,
[Microsoft.Exchange.WebServices.Data.PropertySet]::FirstClassProperties
)
foreach ($singleItem in $Item) {
foreach ($attachment in $singleItem.Attachments) {
$attachment
}
}
}
end {
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
}
}
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/Clear-EWSFolder.ps1
|
Clear-EWSFolder.ps1
|
function Clear-EWSFolder {
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'High'
)]
param (
[Microsoft.Exchange.WebServices.Data.DeleteMode]$DeleteMode = 'MoveToDeletedItems',
[Parameter(
ValueFromPipelineByPropertyName
)]
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $Script:exchangeService,
[Parameter(
ValueFromPipeline,
Mandatory
)]
[Microsoft.Exchange.WebServices.Data.Folder]$Folder,
[switch]$IncludeSubfolders
)
process {
if (-not $Service) {
return
}
if ($PSCmdlet.ShouldProcess(
"Folder: $($Folder.DisplayName)",
"Clear (empty) EWS Folder with$('out' * (-not $IncludeSubfolders)) subfolders"
)) {
$Folder.Empty($DeleteMode, $IncludeSubfolders)
}
}
end {
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
return
}
}
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/New-EWSAppointment.ps1
|
New-EWSAppointment.ps1
|
function New-EWSAppointment {
[OutputType('Microsoft.Exchange.WebServices.Data.Appointment')]
[CmdletBinding(
DefaultParameterSetName = 'inline'
)]
param (
[string[]]$Required,
[string[]]$Optional,
[Parameter(
Mandatory
)]
[string]$Subject,
[Parameter(
Mandatory,
ParameterSetName = 'inline'
)]
[string]$Body,
[Microsoft.Exchange.WebServices.Data.BodyType]$BodyType = 'Text',
[string]$Location,
[Parameter(
Mandatory
)]
[DateTime]$Start,
[Parameter(
Mandatory
)]
[TimeSpan]$Duration,
[string[]]$Attachment,
[Parameter(
ValueFromPipeline,
Mandatory,
ParameterSetName = 'pipe'
)]
$InputObject,
[Parameter(
ParameterSetName = 'pipe'
)]
[switch]$IsHtml,
[Parameter(
ValueFromPipelineByPropertyName
)]
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $script:exchangeService
)
begin {
$data = New-Object Collections.ArrayList
}
process {
if ($InputObject) {
$null = $data.Add($InputObject)
}
}
end {
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
return
}
if ($data.Count) {
if (-not $IsHtml -and $BodyType -eq 'HTML') {
$body = $data | ConvertTo-Html | Out-String
} else {
$body = $data | Out-String
}
}
$appointment = New-Object Microsoft.Exchange.WebServices.Data.Appointment $Service -Property @{
Subject = $Subject
Body = $body
Start = $Start
End = $Start + $Duration
Location = $Location
}
$appointment.Body.BodyType = $BodyType
foreach ($file in $Attachment) {
$null = $appointment.Attachments.AddFileAttachment($file)
}
foreach ($attendee in $Required) {
$null = $appointment.RequiredAttendees.Add(
$attendee
)
}
foreach ($attendee in $Optional) {
$null = $appointment.OptionalAttendees.Add(
$attendee
)
}
if ($Required -or $Optional) {
$method = [Microsoft.Exchange.WebServices.Data.SendInvitationsMode]::SendToAllAndSaveCopy
} else {
$method = [Microsoft.Exchange.WebServices.Data.SendInvitationsMode]::SendToNone
}
$appointment.Save($method)
$appointment
}
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/Get-EWSFolder.ps1
|
Get-EWSFolder.ps1
|
function Get-EWSFolder {
[OutputType('Microsoft.Exchange.WebServices.Data.Folder')]
[CmdletBinding()]
param (
[Parameter(
Mandatory
)]
[ValidateScript({
$root, $rest = $_ -split '\\|/|:|\|'
try {
[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]$root
$true
} catch {
throw "Root folder must belong to collection of WellKnownFolderName: $_"
}
})]
[string]$Path,
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $Script:exchangeService,
[Microsoft.Exchange.WebServices.Data.Mailbox]$Mailbox
)
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
return
}
if (-not $PSBoundParameters.ContainsKey('Mailbox')) {
if (-not ($Mailbox = $connections[$Service])) {
$Mailbox = $Script:Mailbox
}
}
$name = [Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName
$rootFolderName, $remaingPath = $Path -split '\\|/|:|\|'
try {
$rootFolder = New-Object Microsoft.Exchange.WebServices.Data.FolderId $rootFolderName, $Mailbox
} catch {
throw "Unexpected error occured: $_"
}
$root = [Microsoft.Exchange.WebServices.Data.Folder]::Bind(
$Service,
$rootFolder
)
foreach ($item in $remaingPath) {
$filter = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo -ArgumentList @(
$name,
$item
)
$lastItem =
New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+ContainsSubstring -ArgumentList @(
$name,
$item
)
try {
$new = $root.FindFolders($filter,1).Folders[0]
if ($new) {
$root = $new
} else {
$view = New-Object Microsoft.Exchange.WebServices.Data.FolderView 10, 0
do {
$list = $root.FindFolders($lastItem,$view)
$list
$view.Offset += $list.Items.Count
} while ($list.MoreAvailable)
}
} catch {
Write-Error "Could not find subfolder: $item"
$root
return
}
}
$root
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/Connect-EWSService.ps1
|
Connect-EWSService.ps1
|
function Connect-EWSService {
[OutputType('Microsoft.Exchange.WebServices.Data.ExchangeService')]
[CmdletBinding()]
param (
[Parameter(
Mandatory
)]
[String]$Mailbox,
[String]$ServiceUrl,
[Microsoft.Exchange.WebServices.Data.ExchangeVersion]
$Version = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013_SP1,
[Management.Automation.PSCredential]
[Management.Automation.Credential()]
$Credential = [Management.Automation.PSCredential]::Empty
)
$exchangeService = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService $Version
if ($Credential -ne [Management.Automation.PSCredential]::Empty) {
$exchangeService.UseDefaultCredentials = $false
$exchangeService.Credentials = $Credential.GetNetworkCredential()
} else {
$exchangeService.UseDefaultCredentials = $true
}
if ($ServiceUrl) {
$exchangeService.Url = $ServiceUrl
} else {
try {
$exchangeService.AutodiscoverUrl($Mailbox)
} catch {
throw "Failed to identify Url for $Mailbox - $_"
}
}
$Script:exchangeService = $exchangeService
$Script:connections.Add(
$exchangeService,
$Mailbox
)
$exchangeService
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/Move-EWSItem.ps1
|
Move-EWSItem.ps1
|
function Move-EWSItem {
[CmdletBinding(
ConfirmImpact = 'Medium',
SupportsShouldProcess
)]
param (
[Parameter(
Mandatory
)]
[ValidateScript({
$root, $rest = $_ -split '\\|/|:|\|'
try {
[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]$root
$true
} catch {
throw "Root folder must belong to WellKnownFolderName: $_"
}
})]
[string]$DestinationPath,
[Parameter(
ValueFromPipeline,
Mandatory
)]
[Microsoft.Exchange.WebServices.Data.Item]$Item,
[Parameter(
ValueFromPipelineByPropertyName
)]
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $Script:exchangeService
)
begin {
$Mailbox = $Connections[$Service]
$name = [Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName
$rootName, $remaingPath = $DestinationPath -split '\\|/|:|\|'
try {
$rootId = New-Object Microsoft.Exchange.WebServices.Data.FolderId $rootName, $Mailbox
} catch {
throw "Unexpected error occured: $_"
}
$root = [Microsoft.Exchange.WebServices.Data.Folder]::Bind(
$Service,
$rootId
)
foreach ($pathItem in $remaingPath) {
$filter = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo -ArgumentList @(
$name,
$pathItem
)
try {
$new = $root.FindFolders($filter,1).Folders[0]
if ($new) {
$root = $new
}
} catch {
Write-Error "Could not find sub-folder: $pathItem"
$root
return
}
}
$destination = $root
}
process {
if (-not $Service) {
return
}
if ($PSCmdlet.ShouldProcess(
$Item.Subject,
"Move to $DestinationPath"
)) {
$Item.Move($destination.Id)
}
}
end {
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
return
}
}
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/Remove-EWSFolder.ps1
|
Remove-EWSFolder.ps1
|
function Remove-EWSFolder {
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'High'
)]
param (
[Microsoft.Exchange.WebServices.Data.DeleteMode]$DeleteMode = 'MoveToDeletedItems',
[Parameter(
ValueFromPipelineByPropertyName
)]
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $Script:exchangeService,
[Parameter(
ValueFromPipeline,
Mandatory
)]
[Microsoft.Exchange.WebServices.Data.Folder]$Folder
)
process {
if (-not $Service) {
return
}
if ($PSCmdlet.ShouldProcess(
"Folder: $($Folder.DisplayName)",
'Remove EWS Folder'
)) {
$Folder.Delete($DeleteMode)
}
}
end {
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
return
}
}
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/Remove-EWSItem.ps1
|
Remove-EWSItem.ps1
|
function Remove-EWSItem {
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'High'
)]
param (
[Microsoft.Exchange.WebServices.Data.DeleteMode]$DeleteMode = 'MoveToDeletedItems',
[Parameter(
ValueFromPipelineByPropertyName
)]
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $Script:exchangeService,
[Parameter(
ValueFromPipeline,
Mandatory
)]
[Microsoft.Exchange.WebServices.Data.Item]$Item
)
process {
if (-not $Service) {
return
}
if ($PSCmdlet.ShouldProcess(
"Item: $($Item.Subject)",
"Remove using $DeleteMode mode"
)) {
$Item.Delete($DeleteMode)
}
}
end {
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
return
}
}
}
|
PowerShellCorpus/PowerShellGallery/EWS/1.1/Get-EWSItem.ps1
|
Get-EWSItem.ps1
|
function Get-EWSItem {
[OutputType('Microsoft.Exchange.WebServices.Data.Item')]
[CmdletBinding(
DefaultParameterSetName = 'byId'
)]
param (
[Parameter(
Position = 0,
Mandatory
)]
[string]$Filter,
[Parameter(
ParameterSetName = 'byId',
ValueFromPipelineByPropertyName,
Mandatory
)]
[Microsoft.Exchange.WebServices.Data.FolderId]$Id,
[Parameter(
ParameterSetName = 'byName',
Mandatory
)]
[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]$Name,
[Parameter(
ValueFromPipelineByPropertyName
)]
[Microsoft.Exchange.WebServices.Data.ExchangeService]$Service = $Script:exchangeService,
[Microsoft.Exchange.WebServices.Data.BasePropertySet]$PropertySet,
[ValidateRange(1,1000)]
[Int]$PageSize = 100,
[Int]$Limit
)
process {
if (-not $Service) {
return
}
$secondParameter = switch ($PSCmdlet.ParameterSetName) {
byId {
$Id
}
byName {
$Name
}
}
$folder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind(
$Service,
$secondParameter
)
if ($Limit -and $Limit -lt $PageSize) {
$PageSize = $Limit
}
$view = New-Object Microsoft.Exchange.WebServices.Data.ItemView $PageSize, 0
do {
$list = $Folder.FindItems($Filter, $view)
if ($PropertySet -and $list.TotalCount) {
$set = New-Object Microsoft.Exchange.WebServices.Data.PropertySet $PropertySet
$Service.LoadPropertiesForItems(
$list,
$set
) | Out-Null
}
$list
$view.Offset += $list.Items.Count
if ($view.Offset -ge $Limit) {
break
}
} while ($list.MoreAvailable)
}
end {
if (-not $Service) {
Write-Warning 'No connection defined. Use Connect-EWSService first!'
}
}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Test-CompressionUnsupported.ps1
|
Test-CompressionUnsupported.ps1
|
<#
.SYNOPSIS
Test if Pool is compatible with compression
.DESCRIPTION
Test if Pool is compatible with compression.
Test if OS version is -ge 4.1
Test if compression licence is available
Test if compression feature is enabled
Test if Pool is Extreme_Performance only
#>
Function Test-CompressionUnsupported {
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
$Session,
[parameter(Mandatory = $true)]
$Pool
)
Process {
[bool]$Result = $True
If ($Session.SoftwareVersion -lt [version]'4.1') {
#Write-Verbose "Software version lesser than 4.1.0"
$Result = $false
}
If ($Session.isUnityVSA()) {
#Write-Verbose "Array is an UnityVSA"
$Result = $false
}
If (-not (Get-UnityPool -Session $Session -Id $Pool -ErrorAction SilentlyContinue).isExtremePerformance()) {
#Write-Verbose "Pool is not Extreme Performance only"
$Result = $false
}
If ((Get-UnityFeature -Session $Session -id INLINE_COMPRESSION -ErrorAction SilentlyContinue).State -ne 'FeatureStateEnabled') {
#Write-Verbose "Feature INLINE_COMPRESSION is disabled"
$Result = $false
}
If ((Get-UnityLicense -Session $Session -id INLINE_COMPRESSION -ErrorAction SilentlyContinue).isValid -ne $True) {
#Write-Verbose "Licence INLINE_COMPRESSION is not valid"
$Result = $false
}
Write-Verbose "Is compression supported: $Result"
Return $Result
}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Remove-UnityLUNResource.ps1
|
Remove-UnityLUNResource.ps1
|
Function Remove-UnityLUNResource {
<#
.SYNOPSIS
Delete a LUN.
.DESCRIPTION
Delete a LUN ressource (LUN, VMWare VMFS LUN, VMware NFS LUN).
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence
.LINK
https://github.com/equelin/Unity-Powershell
.EXAMPLE
Remove-UnityLUNResource -Name 'LUN01'
Delete the LUN named 'LUN01'
.EXAMPLE
Get-UnityLUNResource -Name 'LUN01' | Remove-UnityLUNResource
Delete the LUN named 'LUN01'. The LUN's informations are provided by the Get-UnityLUNResource through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'LUN ID or Object')]
$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/storageResource/<id>'
$Type = 'LUN Resource'
$TypeName = 'UnityLUN'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityLUN -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityLUN -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
$UnityStorageRessource = Get-UnitystorageResource -Session $sess | ? {($_.Name -like $LUNName) -and ($_.luns.id -like $LUNID)}
#Building the URL
$URI = $URI -replace '<id>',$UnityStorageRessource.id
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE'
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Get-UnityLUNResource.ps1
|
Get-UnityLUNResource.ps1
|
Function Get-UnityLUNResource {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve informations about LUN.
.DESCRIPTION
Queries the EMC Unity array to retrieve informations about LUN.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence
.LINK
https://github.com/equelin/Unity-Powershell
.EXAMPLE
Get-UnityLUNResource
Retrieve information about LUN
.EXAMPLE
Get-UnityLUNResource -Name 'LUN01'
Retrieves information about LUN named LUN01
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'LUN Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'LUN ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$ResultCollection = @()
$URI = '/api/types/lun/instances' #URI for the ressource (example: /api/types/lun/instances)
$TypeName = 'UnityLUN'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Get-URLFromObjectType.ps1
|
Get-URLFromObjectType.ps1
|
function Get-URLFromObjectType {
[CmdletBinding()]
Param (
[parameter(Mandatory = $true, HelpMessage = "IP/FQDN of the array")]
[UnitySession]$Session,
[Parameter(Mandatory = $true,HelpMessage = 'URI')]
[string]$URI,
[parameter(Mandatory = $true, HelpMessage = 'Type associated to the item')]
[string]$TypeName,
[parameter(Mandatory = $false, HelpMessage = 'Ressource Filter')]
[string]$Filter,
[parameter(Mandatory = $false, HelpMessage = 'Compact the response')]
[switch]$Compact,
[parameter(Mandatory = $false, HelpMessage = 'Exceptions')]
[string[]]$Exception = ''
)
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
$type = $TypeName -replace 'Unity',''
($Session.types | where-object {$_.name -eq $type}).Attributes | foreach-object {$fields += $_.Name + ','}
#Remove last ,
$fields = $fields -replace '.$'
$URL = 'https://'+$($Session.Server)+$URI+'?fields='+$fields
If ($Filter) {
$URL = $URL + '&filter=' + $Filter
}
If ($Compact) {
$URL = $URL + '&compact=true'
}
return $URL
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Get-UnityAuth.ps1
|
Get-UnityAuth.ps1
|
Function Get-UnityAuth {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true,Position = 0,HelpMessage = 'EMC Unity FQDN or IP address',ParameterSetName='p1')]
[ValidateNotNullorEmpty()]
[String]$Server,
[Parameter(Mandatory = $true,Position = 0,HelpMessage = 'EMC Unity Rest URI',ParameterSetName='p2')]
[ValidateNotNullorEmpty()]
[String]$URI,
[Parameter(Mandatory = $true,Position = 1,HelpMessage = 'EMC Unity Encoded Password')]
$EncodedPassword,
[Parameter(Mandatory = $false,Position = 2,HelpMessage = 'EMC Unity Cookies')]
[System.Net.CookieContainer]$Cookies
)
If ($PsCmdlet.ParameterSetName -eq 'p1') {
Write-Verbose -Message 'Build the URI'
$URI= 'https://'+$Server+'/api/types/system/instances'
}
Write-Verbose "URI: $URI"
$Request = [System.Net.HttpWebRequest]::Create($URI)
$Request.CookieContainer = $Cookies
$Request.AllowAutoRedirect = $false
$Request.Accept = "application/json"
$Request.ContentType = "application/json"
$Request.Headers.Add("X-EMC-REST-CLIENT","true")
$Request.Headers.Add('Authorization',"Basic $($EncodedPassword)")
Write-Verbose "Sending authentication request"
Try {
$NewResponse = $Request.GetResponse()
$NewResponse.Close()
}
Catch {
Show-RequestException -Exception $_
throw
}
Write-Verbose "Processing cookies"
Foreach ($cookie in $NewResponse.Cookies) {
Write-Verbose "Adding cookie: $($cookie.Name)"
$Cookies.Add($cookie)
}
Write-Verbose "Response Status Code: $($NewResponse.StatusCode)"
If ($NewResponse.StatusCode -eq 'OK') {
$headers = @{}
$headers["Accept"] = "application/json"
$headers["X-EMC-REST-CLIENT"] = "true"
$headers["EMC-CSRF-TOKEN"] = $NewResponse.Headers.item('EMC-CSRF-TOKEN')
$result = @{}
$result['Headers'] = $headers
$result['Cookies'] = $Cookies.GetCookies($uri)
return $result
} else {
Get-UnityAuth -URI $NewResponse.Headers.item('Location') -EncodedPassword $EncodedPassword -Cookies $Cookies
}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Find-FromFilter.ps1
|
Find-FromFilter.ps1
|
Function Find-FromFilter {
[CmdletBinding()]
Param (
[parameter(Mandatory = $true)]
$Data,
[parameter(Mandatory = $true)]
[String]$Parameter,
[parameter(Mandatory = $true)]
$Filter
)
Process {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
Foreach ($F in $Filter) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Filtering result(s) on parameter $Parameter with value $F"
$Result = $Data | Where-Object {$_."$Parameter" -like $F}
Write-Debug -Message "[$($MyInvocation.MyCommand)] Found $($Result.Count) item(s)"
$Result
}
}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Get-UnityHostContainerReco.ps1
|
Get-UnityHostContainerReco.ps1
|
Function Get-UnityHostContainerReco {
<#
.SYNOPSIS
Get the hostContainer recommendations for importing ESXi servers
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
#>
[CmdletBinding()]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#vCenter
[Parameter(Mandatory = $true,Position = 1,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'The IP address of the vCenter server')]
[String[]]$Address,
[Parameter(Mandatory = $true,HelpMessage = 'The user name to access vCenter server')]
[string]$Username,
[Parameter(Mandatory = $true,HelpMessage = 'The password to connect to vCenter server')]
[String]$Password
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing arrays
$
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
Foreach ($a in $Address) {
# Creation of the body hash
$body = @{}
# address parameter
$body["address"] = "$a"
# username parameter
$body["username"] = "$Username"
# password parameter
$body["password"] = "$Password"
If ($Sess.TestConnection()) {
#Building the URI
$URI = 'https://'+$sess.Server+'/api/types/hostContainer/action/recommend'
Write-Verbose "URI: $URI"
#Sending the request
$request = Send-UnityRequest -uri $URI -Session $Sess -Method 'POST' -Body $Body
Write-Verbose "Request status code: $($request.StatusCode)"
If ($request.StatusCode -eq '200') {
#Formating the result
$results = ($request.content | ConvertFrom-Json).content
Write-Output $results
}
} else {
Write-Warning "You are no longer connected to EMC Unity array: $($Sess.Server)"
}
}
}
}
End {}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Send-UnityRequest.ps1
|
Send-UnityRequest.ps1
|
function Send-UnityRequest {
[CmdletBinding()]
Param (
[parameter(Mandatory = $true, HelpMessage = "Request URI")]
[string]$URI,
[Parameter(Mandatory = $true,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[parameter(Mandatory = $true, HelpMessage = "Enter request type (GET POST DELETE)")]
[string]$Method,
[parameter(Mandatory = $false, HelpMessage = "Body of the message")]
[array]$body
)
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Request
If (($Method -eq 'GET') -or ($type -eq 'DELETE')) {
Try
{
$data = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Websession $Session.Websession -Headers $session.headers -Method $Method
return $data
}
Catch
{
Show-RequestException -Exception $_
throw
}
}
If (($Method -eq 'POST') -or ($type -eq 'PUT')) {
Try
{
$json = $body | ConvertTo-Json -Depth 10
$data = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Body $json -Websession $Session.Websession -Headers $session.headers -Method $Method -TimeoutSec 600
return $data
}
Catch
{
Show-RequestException -Exception $_
throw
}
}
If ($Method -eq 'DELETE') {
Try
{
If ($body) {
$json = $body | ConvertTo-Json -Depth 10
$data = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Body $json -Websession $Session.Websession -Headers $session.headers -Method $Method
} else {
$data = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Websession $Session.Websession -Headers $session.headers -Method $Method
}
return $data
}
Catch
{
Show-RequestException -Exception $_
throw
}
}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Test-UnityConnection.ps1
|
Test-UnityConnection.ps1
|
Function Test-UnityConnection {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
[Array]$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true})
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
}
Process {
Foreach ($Sess in $session) {
Write-Verbose "Processing Array: $($sess.Server)"
$URI = 'https://'+$sess.Server+'/api/types/system/instances'
Write-Verbose "URI: $URI"
Try {
$request = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Websession $sess.Websession -Headers $sess.headers -Method 'GET'
}
Catch {
$global:DefaultUnitySession |
where-object {$_.SessionId -eq $sess.SessionId} |
foreach {
$currentObject = $_
$currentObject.IsConnected = $false
$currentObject
} | Out-Null
Return $false
}
}
Return $True
}
End {}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/ConvertTo-Hashtable.ps1
|
ConvertTo-Hashtable.ps1
|
function ConvertTo-Hashtable {
[CmdletBinding()]
Param (
[parameter(Mandatory = $true)]
$Data
)
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Building the result collection
Foreach ($D in $Data) {
$HashTable = @{}
$D |
get-member -MemberType NoteProperty |
ForEach-Object {
$HashTable.add($_.name,$D."$($_.name)")
}
# Output results
$HashTable
}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Update-TitleBarForUnityConnection.ps1
|
Update-TitleBarForUnityConnection.ps1
|
<# .Description
Set PowerShell title bar to reflect currently connected Unity servers' names
#>
function Update-TitleBarForUnityConnection {
$strOrigWindowTitle = $host.ui.RawUI.WindowTitle
## the window titlebar text without the "connected to.." Unity info
$strWinTitleWithoutOldUnityConnInfo = $strOrigWindowTitle -replace "(; )?Connected to( \d+)? Unity.+", ""
## the number of Unity servers to which still connected
$intNumConnectedUnityServers = ($Global:DefaultUnitySession | Measure-Object).Count
$strNewWindowTitle = "{0}{1}{2}" -f $strWinTitleWithoutOldUnityConnInfo, $(if ((-not [System.String]::IsNullOrEmpty($strWinTitleWithoutOldUnityConnInfo)) -and ($intNumConnectedUnityServers -gt 0)) {"; "}), $(
if ($intNumConnectedUnityServers -gt 0) {
if ($intNumConnectedUnityServers -eq 1) {"Connected to Unity {0} as {1}" -f $Global:DefaultUnitySession[0].Server, $Global:DefaultUnitySession[0].User}
else {"Connected to {0} Unity servers: {1}." -f $intNumConnectedUnityServers, (($Global:DefaultUnitySession | Foreach-Object {$_.Server}) -Join ", ")}
} ## end if
#else {"Not Connected to Unity"}
) ## end -f call
$host.ui.RawUI.WindowTitle = $strNewWindowTitle
} ## end fn
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Get-UnityItemByKey.ps1
|
Get-UnityItemByKey.ps1
|
<#
.SYNOPSIS
#>
Function Get-UnityItemByKey {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $True,HelpMessage = 'EMC Unity Session')]
$session,
[Parameter(Mandatory = $True,HelpMessage = 'URI')]
[String]$URI,
[Parameter(Mandatory = $True,HelpMessage = 'Typename')]
[String]$Typename,
[Parameter(Mandatory = $True,HelpMessage = 'Key')]
[String]$Key,
[Parameter(Mandatory = $False,HelpMessage = 'Value')]
[String[]]$Value,
[parameter(Mandatory = $False, HelpMessage = 'Ressource Filter')]
[string]$Filter
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
}
Process {
If ($Session.TestConnection()) {
#Building the URL from Object Type.
If ($Filter) {
$URL = Get-URLFromObjectType -Session $Session -URI $URI -TypeName $TypeName -Compact -Filter $Filter
} else {
$URL = Get-URLFromObjectType -Session $Session -URI $URI -TypeName $TypeName -Compact
}
Write-Debug -Message "[$($MyInvocation.MyCommand)] URL: $URL"
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Session -Method 'GET'
#Formating the result. Converting it from JSON to a Powershell object
$Results = ($request.content | ConvertFrom-Json).entries.content
#Building the result collection (Add ressource type)
If ($Results) {
$ResultsFiltered = @()
If (-not $Value) {
$Value = '*'
}
# Results filtering
$ResultsFiltered += Find-FromFilter -Parameter $Key -Filter $Value -Data $Results
If ($ResultsFiltered) {
$ResultCollection = ConvertTo-Hashtable -Data $ResultsFiltered
Foreach ($Result in $ResultCollection) {
# Instantiate and output object
New-Object -TypeName $TypeName -Property $Result
} # End Foreach ($Result in $ResultCollection)
} # End If ($ResultsFiltered)
} # End If ($Results)
} # End If ($Sess.TestConnection())
}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Unblock-UnityCerts.ps1
|
Unblock-UnityCerts.ps1
|
Function Unblock-UnityCerts {
# Hack for allowing untrusted SSL certs with https connexions
Add-Type -TypeDefinition @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object -TypeName TrustAllCertsPolicy
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Add-UnityObjectType.ps1
|
Add-UnityObjectType.ps1
|
#Deprecated, replaced by ConvertTo-Hashtable
function Add-UnityObjectType {
[CmdletBinding()]
Param (
[parameter(Mandatory = $true)]
$Data,
[parameter(Mandatory = $true)]
[string]$TypeName
)
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Building the result collection (Add type)
Foreach ($D in $Data) {
$object = New-Object $TypeName
$Data | get-member -type NoteProperty | foreach-object {
If ($D."$($_.Name)") {
$object."$($_.Name)" = $D."$($_.Name)"
}
}
#Adding the request result object to the result's collection array
Write-Output $object
}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Private/Show-RequestException.ps1
|
Show-RequestException.ps1
|
Function Show-RequestException {
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
$Exception
)
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Exception catch when there's a connectivity problem with the array
If ($Exception.Exception.InnerException) {
Write-Host "Please verify the connectivity with the array" -foreground yellow
Write-Host
Write-Host "Error details: $($Exception.Exception.InnerException.Message)" -foreground yellow
Write-Host
}
#Exception catch when the rest request return an error
If ($Exception.Exception.Response) {
$result = $Exception.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($result)
$responseBody = $reader.ReadToEnd()
$JSON = $responseBody | ConvertFrom-Json
Write-Host "The array sends an error message:" -foreground yellow
Write-Host
Write-Host "Error code: $($Exception.Exception.Response.StatusCode)" -foreground yellow
Write-Host "Error description: $($Exception.Exception.Response.StatusDescription)" -foreground yellow
Write-Host "Error details: $responseBody" -foreground yellow
Write-Host
}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityDnsServer.ps1
|
Set-UnityDnsServer.ps1
|
Function Set-UnityDNSServer {
<#
.SYNOPSIS
Modifies DNS Servers parameters.
.DESCRIPTION
Modifies DNS Servers parameters.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER addresses
New list of IP addresses to replace the exsting address list for this DNS server.
.EXAMPLE
Set-UnityDnsServer -Addresses '192.168.0.1','192.168.0.2'
replace the exsting address list for this DNS server with this new list.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'New list of IP addresses to replace the exsting address list for this DNS server.')]
[String[]]$Addresses
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/dnsServer/<id>/action/modify'
$Type = 'DNS Server'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
$Object = Get-UnityDnsServer -Session $Sess
$ObjectID = $Object.id
#### REQUEST BODY
# Creation of the body hash
$body = @{}
$body['addresses'] = @()
Foreach ($Addresse in $Addresses) {
$body["addresses"] += $Addresse
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectID")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityDnsServer -Session $Sess
}
} else {
Write-Information -MessageData "You are no longer connected to EMC Unity array: $($Sess.Server)"
}
}
}
End {}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityCIFSShare.ps1
|
Get-UnityCIFSShare.ps1
|
Function Get-UnityCIFSShare {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve informations about CIFS Share.
.DESCRIPTION
Queries the EMC Unity array to retrieve informations about CIFS Share.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityCIFSShare
Retrieve information about CIFS Share
.EXAMPLE
Get-UnityCIFSShare -Name 'SHARE01'
Retrieves information about CIFS Share named SHARE01
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'CIFS Share Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'CIFS Share ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/cifsShare/instances' #URI
$TypeName = 'UnityCIFSShare'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/New-UnityFileDnsServer.ps1
|
New-UnityFileDnsServer.ps1
|
Function New-UnityFileDNSServer {
<#
.SYNOPSIS
Create a new DNS server for a NAS Server.
.DESCRIPTION
Create a new DNS server for a NAS Server.
Only one instance can be created per NAS server.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER nasServer
ID of the NAS server to which the DNS server belongs.
.PARAMETER domain
DNS domain name
.PARAMETER addresses
Prioritized list of one to three IPv4 and/or IPv6 addresses of DNS server(s) for the domain
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
New-UnityFileDNSServer -nasServer 'nas_1' -domain 'example.com' -ip '192.168.0.1','192.168.0.2'
Create a DNS file server associated to NAS server 'nas_1'
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 1,HelpMessage = 'ID of the NAS server to which the DNS server belongs')]
$nasServer,
[Parameter(Mandatory = $true,HelpMessage = 'DNS domain name')]
[string]$domain,
[Parameter(Mandatory = $true,HelpMessage = 'Prioritized list of one to three IPv4 and/or IPv6 addresses of DNS servers for the domain')]
[String[]]$addresses
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
## Variables
$URI = '/api/types/fileDNSServer/instances'
$Type = 'File DNS Server'
$StatusCode = 201
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
#### REQUEST BODY
# Creation of the body hash
$body = @{}
# nasServer argument
$body["nasServer"] = @{}
$nasServerArg = @{}
$nasServerArg["id"] = "$($nasServer)"
$body["nasServer"] = $nasServerArg
#Addresses argument
$body['addresses'] = @()
Foreach ($Addresse in $Addresses) {
$body["addresses"] += $Addresse
}
If ($PSBoundParameters.ContainsKey('domain')) {
$body["domain"] = "$($domain)"
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
##Building the URL
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Create $Type $domain")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
Write-Verbose "Request status code: $($request.StatusCode)"
If ($request.StatusCode -eq $StatusCode) {
#Formating the result. Converting it from JSON to a Powershell object
$results = ($request.content | ConvertFrom-Json).content
Write-Verbose "$Type with the ID $($results.id) has been created"
#Executing Get-UnityUser with the ID of the new user
Get-UnityFileDNSServer -Session $Sess -ID $results.id
} # End If ($request.StatusCode -eq $StatusCode)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnityMgmtInterface.ps1
|
Remove-UnityMgmtInterface.ps1
|
Function Remove-UnityMgmtInterface {
<#
.SYNOPSIS
Delete a file interface.
.DESCRIPTION
Delete a Nas Server.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
Management interface ID or Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnityMgmtInterface -ID 'mgmt_ipv4'
Delete the management interface with ID 'mgmt_ipv4'
.EXAMPLE
Get-UnityMgmtInterface -Name 'mgmt_ipv4' | Remove-UnityMgmtInterface
Delete the management interface with ID 'mgmt_ipv4'. The management interface informations are provided by the Get-UnityMgmtInterface through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Management interface ID or Object')]
$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/mgmtInterface/<id>'
$Type = 'Management Interface'
$TypeName = 'UnityMgmtInterface'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityMgmtInterface -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityMgmtInterface -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE'
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnityHostIPPort.ps1
|
Remove-UnityHostIPPort.ps1
|
Function Remove-UnityHostIPPort {
<#
.SYNOPSIS
Delete a host IP port.
.DESCRIPTION
Delete a host IP port.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
Host IP Port ID or Object
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnityHostIPPort -ID 'HostNetworkAddress_45'
Delete the host with ID 'HostNetworkAddress_45'
.EXAMPLE
Get-UnityHostIPPort -ID 'HostNetworkAddress_45' | Remove-UnityHostIPPort
Delete the host with ID 'HostNetworkAddress_45'. host informations are provided by the Get-UnityHostIPPort through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Host IP Port ID or Object')]
$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/hostIPPort/<id>'
$Type = 'Host IP Port'
$TypeName = 'UnityHostIPPort'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityHostIPPort -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityHostIPPort -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE'
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnityNFSShare.ps1
|
Remove-UnityNFSShare.ps1
|
Function Remove-UnityNFSShare {
<#
.SYNOPSIS
Deletes NFS share.
.DESCRIPTION
Deletes NFS share.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
SpeNFS an UnitySession Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnityNFSShare -ID 'NFSShare_2'
Delete the NFS share with id 'NFSShare_2'
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#NFS Share ID or Object.
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'NFS Share ID or Object.')]
$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/storageResource/<id>/action/modifyFilesystem'
$Type = 'Share NFS'
$TypeName = 'UnityNFSShare'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityNFSShare -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityNFSShare -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
$UnityStorageResource = Get-UnitystorageResource -Session $sess | Where-Object {($_.filesystem.id -like $Object.filesystem.id)}
#### REQUEST BODY
# Creation of the body hash
$body = @{}
$body["nfsShareDelete"] = @()
$nfsShareDeleteParameters = @{}
$nfsShareDeleteParameters["nfsShare"] = @{}
$nfsShareParameters = @{}
$nfsShareParameters['id'] = $ObjectID
$nfsShareDeleteParameters["nfsShare"] = $nfsShareParameters
$body["nfsShareDelete"] += $nfsShareDeleteParameters
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$UnityStorageResource.id
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityFilesystem.ps1
|
Set-UnityFilesystem.ps1
|
Function Set-UnityFilesystem {
<#
.SYNOPSIS
Modifies filesystem parameters.
.DESCRIPTION
Modifies filesystem parameters.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Name
New Name of the filesystem
.PARAMETER Description
Filesystem Description
.PARAMETER snapSchedule
ID of a protection schedule to apply to the filesystem
.PARAMETER isSnapSchedulePaused
Is assigned snapshot schedule is paused ? (Default is false)
.PARAMETER isThinEnabled
Indicates whether to enable thin provisioning for file system. Default is $True
.PARAMETER Size
Filesystem Size
.PARAMETER hostIOSize
Typical write I/O size from the host to the file system
.PARAMETER isCacheDisabled
Indicates whether caching is disabled
.PARAMETER accessPolicy
Access policy
.PARAMETER poolFullPolicy
Behavior to follow when pool is full and a write to this filesystem is attempted
.PARAMETER tieringPolicy
Filesystem tiering policy
.PARAMETER isCIFSSyncWritesEnabled
Indicates whether the CIFS synchronous writes option is enabled for the file system
.PARAMETER isCIFSOpLocksEnabled
Indicates whether opportunistic file locks are enabled for the file system
.PARAMETER isCIFSNotifyOnWriteEnabled
Indicates whether the system generates a notification when the file system is written to
.PARAMETER isCIFSNotifyOnAccessEnabled
Indicates whether the system generates a notification when a user accesses the file system
.PARAMETER cifsNotifyOnChangeDirDepth
Indicates the lowest directory level to which the enabled notifications apply, if any
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Set-UnityFilesystem -Name 'FS01' -Description 'Modified description'
Change the description of the filesystem named FS01
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#SetFilesystem
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Filesystem ID or Object')]
[String[]]$ID,
[Parameter(Mandatory = $false,HelpMessage = 'New Name of the filesystem')]
[String]$Name,
[Parameter(Mandatory = $false,HelpMessage = 'Filesystem Description')]
[String]$Description,
[Parameter(Mandatory = $false,HelpMessage = 'ID of a protection schedule to apply to the filesystem')]
[String]$snapSchedule,
[Parameter(Mandatory = $false,HelpMessage = 'Is assigned snapshot schedule is paused ? (Default is false)')]
[bool]$isSnapSchedulePaused = $false,
#fsParameters
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether to enable thin provisioning for file system')]
[String]$isThinEnabled = $true,
[Parameter(Mandatory = $false,HelpMessage = 'Filesystem Size in Bytes')]
[uint64]$Size,
[Parameter(Mandatory = $false,HelpMessage = 'Typical write I/O size from the host to the file system')]
[HostIOSizeEnum]$hostIOSize,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether caching is disabled')]
[bool]$isCacheDisabled,
[Parameter(Mandatory = $false,HelpMessage = 'Access policy')]
[AccessPolicyEnum]$accessPolicy,
[Parameter(Mandatory = $false,HelpMessage = 'Behavior to follow when pool is full and a write to this filesystem is attempted')]
[ResourcePoolFullPolicyEnum]$poolFullPolicy,
##fastVPParameterseters
[Parameter(Mandatory = $false,HelpMessage = 'Filesystem tiering policy')]
[TieringPolicyEnum]$tieringPolicy,
#cifsFilesystemParameters
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether the CIFS synchronous writes option is enabled for the file system')]
[bool]$isCIFSSyncWritesEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether opportunistic file locks are enabled for the file system')]
[bool]$isCIFSOpLocksEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether the system generates a notification when the file system is written to')]
[bool]$isCIFSNotifyOnWriteEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether the system generates a notification when a user accesses the file system')]
[bool]$isCIFSNotifyOnAccessEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates the lowest directory level to which the enabled notifications apply, if any')]
[int]$cifsNotifyOnChangeDirDepth
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/storageResource/<id>/action/modifyFilesystem'
$Type = 'Filesystem'
$TypeName = 'UnityFilesystem'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityFilesystem -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityFilesystem -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
$UnitystorageResource = Get-UnitystorageResource -Session $sess | Where-Object {($_.filesystem.id -like $ObjectID)}
#### REQUEST BODY
# Creation of the body hash
$body = @{}
# Name parameter
If ($NewName) {
$body["name"] = "$($Name)"
}
# Domain parameter
If ($Description) {
$body["description"] = "$($Description)"
}
If (($PSBoundParameters.ContainsKey('Size')) -or ($PSBoundParameters.ContainsKey('isThinEnabled')) -or ($PSBoundParameters.ContainsKey('hostIOSize')) -or ($PSBoundParameters.ContainsKey('tieringPolicy')) -or ($PSBoundParameters.ContainsKey('isCacheDisabled')) -or ($PSBoundParameters.ContainsKey('accessPolicy')) -or ($PSBoundParameters.ContainsKey('poolFullPolicy'))) {
# fsParameters parameter
$body["fsParameters"] = @{}
$fsParameters = @{}
# Size
If ($PSBoundParameters.ContainsKey('Size')) {
$fsParameters["Size"] = $Size
}
# isThinEnabled
If ($PSBoundParameters.ContainsKey('isThinEnabled')) {
$fsParameters["isThinEnabled"] = $isThinEnabled
}
# hostIOSize
If ($PSBoundParameters.ContainsKey('hostIOSize')) {
$fsParameters["hostIOSize"] = $hostIOSize
}
# fastVPParameters
If ($PSBoundParameters.ContainsKey('tieringPolicy')) {
$fastVPParameters = @{}
$fastVPParameters['tieringPolicy'] = $tieringPolicy
$fsParameters["fastVPParameters"] = $fastVPParameters
}
# isCacheDisabled
If ($PSBoundParameters.ContainsKey('isCacheDisabled')) {
$fsParameters["isThinEnabled"] = $isCacheDisabled
}
# accessPolicy
If ($PSBoundParameters.ContainsKey('accessPolicy')) {
$fsParameters["accessPolicy"] = $accessPolicy
}
# poolFullPolicy
If ($PSBoundParameters.ContainsKey('poolFullPolicy')) {
$fsParameters["poolFullPolicy"] = $poolFullPolicy
}
$body["fsParameters"] = $fsParameters
}
If (($PSBoundParameters.ContainsKey('isCIFSSyncWritesEnabled')) -or ($PSBoundParameters.ContainsKey('isCIFSOpLocksEnabled')) -or ($PSBoundParameters.ContainsKey('isCIFSNotifyOnWriteEnabled')) -or ($PSBoundParameters.ContainsKey('isCIFSNotifyOnAccessEnabled')) -or ($PSBoundParameters.ContainsKey('cifsNotifyOnChangeDirDepth'))) {
$body["cifsFsParameters"] = @{}
$cifsFsParameters = @{}
# isCIFSSyncWritesEnabled
If ($PSBoundParameters.ContainsKey('isCIFSSyncWritesEnabled')) {
$fsParameters["isCIFSSyncWritesEnabled"] = $isCIFSSyncWritesEnabled
}
# isCIFSOpLocksEnabled
If ($PSBoundParameters.ContainsKey('isCIFSOpLocksEnabled')) {
$fsParameters["isCIFSOpLocksEnabled"] = $isCIFSOpLocksEnabled
}
# isCIFSNotifyOnWriteEnabled
If ($PSBoundParameters.ContainsKey('isCIFSNotifyOnWriteEnabled')) {
$fsParameters["isCIFSNotifyOnWriteEnabled"] = $isCIFSNotifyOnWriteEnabled
}
# isCIFSNotifyOnAccessEnabled
If ($PSBoundParameters.ContainsKey('isCIFSNotifyOnAccessEnabled')) {
$fsParameters["isCIFSNotifyOnAccessEnabled"] = $isCIFSNotifyOnAccessEnabled
}
# cifsNotifyOnChangeDirDepth
If ($PSBoundParameters.ContainsKey('cifsNotifyOnChangeDirDepth')) {
$fsParameters["cifsNotifyOnChangeDirDepth"] = $cifsNotifyOnChangeDirDepth
}
$body["cifsFsParameters"] = $cifsFsParameters
}
#snapScheduleParameters
If ($snapSchedule) {
$body["snapScheduleParameters"] = @{}
$snapScheduleParameters = @{}
$snapScheduleParam = @{}
$snapScheduleParam["id"] ="$($snapSchedule)"
$snapScheduleParameters["snapSchedule"] = $snapScheduleParam
$snapScheduleParameters["isSnapSchedulePaused"]= "$($isSnapSchedulePaused)"
$body["snapScheduleParameters"] = $snapScheduleParameters
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$UnitystorageResource.id
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityFilesystem -Session $Sess -ID $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityFileInterface.ps1
|
Set-UnityFileInterface.ps1
|
Function Set-UnityFileInterface {
<#
.SYNOPSIS
Modifies NAS Server parameters.
.DESCRIPTION
Modifies NAS Server parameters.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
File interface ID or Object
.PARAMETER ipPort
Physical port or link aggregation on the storage processor on which the interface is running
.PARAMETER ipAddress
IP address of the network interface
.PARAMETER netmask
IPv4 netmask for the network interface, if it uses an IPv4 address
.PARAMETER v6PrefixLength
IPv6 prefix length for the interface, if it uses an IPv6 address
.PARAMETER gateway
IPv4 or IPv6 gateway address for the network interface
.PARAMETER vlanId
LAN identifier for the interface. The interface uses the identifier to accept packets that have matching VLAN tags. Values are 1 - 4094.
.PARAMETER isPreferred
Sets the current IP interface as preferred for associated for file-based storage and unsets the previous one
.PARAMETER replicationPolicy
Indicates the status of the NAS server object operating as a replication destination
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Set-UnityFileInterface -ID 'if_1' -ipAddress '192.168.0.1'
Change ip of the file interface with ID 'if_1'
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'File interface ID or Object')]
$ID,
[Parameter(Mandatory = $false,HelpMessage = 'Physical port or link aggregation on the storage processor on which the interface is running')]
$ipPort,
[Parameter(Mandatory = $false,HelpMessage = 'IP address of the network interface')]
[ipaddress]$ipAddress,
[Parameter(Mandatory = $false,HelpMessage = 'IPv4 netmask for the network interface, if it uses an IPv4 address')]
[ipaddress]$netmask,
[Parameter(Mandatory = $false,HelpMessage = 'IPv6 prefix length for the interface, if it uses an IPv6 address')]
[String]$v6PrefixLength,
[Parameter(Mandatory = $false,HelpMessage = 'IPv4 or IPv6 gateway address for the network interface')]
[ipaddress]$gateway,
[Parameter(Mandatory = $false,HelpMessage = ' VLAN identifier for the interface. The interface uses the identifier to accept packets that have matching VLAN tags. Values are 1 - 4094.')]
[int]$vlanId,
[Parameter(Mandatory = $false,HelpMessage = 'Sets the current IP interface as preferred for associated for file-based storage and unsets the previous one')]
[bool]$isPreferred,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates the status of the NAS server object operating as a replication destination')]
[ReplicationPolicyEnum]$replicationPolicy
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/fileInterface/<id>/action/modify '
$Type = 'File Interface'
$TypeName = 'UnityFileInterface'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityFileInterface -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityFileInterface -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
If ($PSBoundParameters.ContainsKey('nasServer')) {
# nasServer argument
$body["nasServer"] = @{}
$FileInterfaceArg = @{}
$FileInterfaceArg["id"] = "$($FileInterface)"
$body["nasServer"] = $FileInterfaceArg
}
If ($PSBoundParameters.ContainsKey('ipPort')) {
# ipPort argument
$body["ipPort"] = @{}
$ipPortArg = @{}
$ipPortArg["id"] = "$($ipPort)"
$body["ipPort"] = $ipPortArg
}
# ipAddress argument
If ($PSBoundParameters.ContainsKey('ipAddress')) {
$body["ipAddress"] = "$ipAddress"
}
If ($PSBoundParameters.ContainsKey('netmask')) {
$body["netmask"] = "$netmask"
}
If ($PSBoundParameters.ContainsKey('v6PrefixLength')) {
$body["v6PrefixLength"] = "$v6PrefixLength"
}
If ($PSBoundParameters.ContainsKey('gateway')) {
$body["gateway"] = "$gateway"
}
If ($PSBoundParameters.ContainsKey('vlanId')) {
$body["vlanId"] = $vlanId
}
If ($PSBoundParameters.ContainsKey('isPreferred')) {
$body["isPreferred"] = $isPreferred
}
If ($PSBoundParameters.ContainsKey('replicationPolicy')) {
$body["replicationPolicy"] = "$replicationPolicy"
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityFileInterface -Session $Sess -id $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnityLUN.ps1
|
Remove-UnityLUN.ps1
|
Function Remove-UnityLUN {
<#
.SYNOPSIS
Delete a LUN.
.DESCRIPTION
Delete a LUN.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
LUN ID or Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnityLUN -Name 'LUN01'
Delete the LUN named 'LUN01'
.EXAMPLE
Get-UnityLUN -Name 'LUN01' | Remove-UnityLUN
Delete the LUN named 'LUN01'. The LUN's informations are provided by the Get-UnityLUN through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'LUN ID or LUN Object')]
$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/storageResource/<id>'
$Type = 'LUN Resource'
$TypeName = 'UnityLUN'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityLUN -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityLUN -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
$UnityStorageResource = Get-UnitystorageResource -Session $sess | ? {($_.Name -like $ObjectName) -and ($_.luns.id -like $ObjectID)}
#Building the URL
$FinalURI = $URI -replace '<id>',$UnityStorageResource.id
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE'
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityHost.ps1
|
Get-UnityHost.ps1
|
Function Get-UnityHost {
<#
.SYNOPSIS
View details about host configuration on the system.
.DESCRIPTION
View details about host configuration on the system.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityHost
Retrieve information about all hosts
.EXAMPLE
Get-UnityHost -Name 'ESX01'
Retrieves information about host named 'ESX01'
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Host Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Host ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/host/instances' #URI
$TypeName = 'UnityHost'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnityVMwareNFS.ps1
|
Remove-UnityVMwareNFS.ps1
|
Function Remove-UnityVMwareNFS {
<#
.SYNOPSIS
Delete a filesystem.
.DESCRIPTION
Delete a filesystem.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
Filesystem ID or Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnityVMwareNFS -ID 'fs_1'
Delete the filesystem named 'fs_1'
.EXAMPLE
Get-UnityVMwareNFS -Name 'FS01' | Remove-UnityVMwareNFS
Delete the filesystem named 'FS01'. The filesystem's informations are provided by the Get-UnityVMwareNFS through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Filesystem ID or Object.')]
$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/storageResource/<id>'
$Type = 'VMware NFS LUN'
$TypeName = 'UnityFilesystem'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityVMwareNFS -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityVMwareNFS -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
$UnityStorageResource = Get-UnitystorageResource -Session $sess | ? {($_.Name -like $ObjectName) -and ($_.filesystem.id -like $ObjectID)}
#Building the URL
$FinalURI = $URI -replace '<id>',$UnityStorageResource.id
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE'
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID: $ObjectID has been deleted"
}
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityVMwareLUN.ps1
|
Set-UnityVMwareLUN.ps1
|
Function Set-UnityVMwareLUN {
<#
.SYNOPSIS
Modifies VMware block LUN parameters.
.DESCRIPTION
Modifies VMware block LUN parameters.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.PARAMETER ID
ID or Object.
.PARAMETER Name
New name of the VMware VMFS datastore unique to the system.
.PARAMETER Description
New description of the VMware VMFS datastore.
.PARAMETER Size
New LUN size. The size parameter can be greater than the current LUN size in this case the LUN is expanded.
.PARAMETER fastVPParameters
FAST VP settings for the storage resource
.PARAMETER isCompressionEnabled
Indicates whether to enable inline compression for the LUN. Default is True
.PARAMETER snapSchedule
Snapshot schedule settings for the VMware VMFS datastore, as defined by the snapScheduleParameters.
.PARAMETER host
List of host to grant access to LUN.
.PARAMETER accessMask
Host access mask. Might be:
- NoAccess: No access.
- Production: Access to production LUNs only.
- Snapshot: Access to LUN snapshots only.
- Both: Access to both production LUNs and their snapshots.
.PARAMETER append
Add new host access to the existing configuration.
.PARAMETER snapSchedule
Snapshot schedule assigned to the storage resource
.PARAMETER isSnapSchedulePaused
Indicates whether the assigned snapshot schedule is paused.
.EXAMPLE
Set-UnityVMwareLUN -ID 'sv_78' -Description 'Modified description'
Change the description of the VMware bock LUN with ID 'sv_78'.
.EXAMPLE
Set-UnityVMwareLUN -ID 'sv_78' -Pool 'pool_14' -host 'Host_12' -accessMask 'Production' -Append
Grant 'production' access to host 'Host_12' to VMware bock LUN with ID 'sv_78'.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'LUN ID or LUN Object')]
[Object[]]$ID,
[Parameter(Mandatory = $false,HelpMessage = 'New Name of the LUN')]
[String]$Name,
[Parameter(Mandatory = $false,HelpMessage = 'New LUN Description')]
[String]$Description,
# lunParameters
[Parameter(Mandatory = $false,HelpMessage = 'New LUN Size in Bytes')]
[uint64]$Size,
[Parameter(Mandatory = $false,HelpMessage = 'FAST VP settings for the storage resource')]
[TieringPolicyEnum]$fastVPParameters,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether to enable inline compression for the LUN. Default is True')]
[bool]$isCompressionEnabled,
# snapScheduleParameters
[Parameter(Mandatory = $false,HelpMessage = 'ID of a protection schedule to apply to the storage resource')]
[String]$snapSchedule,
[Parameter(Mandatory = $false,HelpMessage = 'Is assigned snapshot schedule is paused ? (Default is false)')]
[bool]$isSnapSchedulePaused = $false,
# hostParameters
[Parameter(Mandatory = $false,HelpMessage = 'Host to grant access to LUN')]
[String[]]$host,
[Parameter(Mandatory = $false,HelpMessage = 'Append Host access to existing configuration')]
[Switch]$append,
[Parameter(Mandatory = $false,HelpMessage = 'Host access mask')]
[HostLUNAccessEnum]$accessMask = 'Production'
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/storageResource/<id>/action/modifyVmwareLun'
$Type = 'VMware LUN'
$TypeName = 'UnityLUN'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
Switch -wildcard ($i.GetType().Name)
{
"String" {
$Object = get-UnityVMwareLUN -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName*" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityVMwareLUN -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
$UnitystorageResource = Get-UnitystorageResource -Session $sess | Where-Object {($_.Name -like $ObjectName) -and ($_.luns.id -like $ObjectID)}
# Creation of the body hash
$body = @{}
# Name parameter
If ($PSBoundParameters.ContainsKey('Name')) {
$body["name"] = $Name
}
# Description parameter
If ($PSBoundParameters.ContainsKey('description')) {
$body["description"] = $Description
}
# lunParameters parameter
If (($PSBoundParameters.ContainsKey('size')) -or ($PSBoundParameters.ContainsKey('host')) -or ($PSBoundParameters.ContainsKey('fastVPParameters')) -or ($PSBoundParameters.ContainsKey('isCompressionEnabled'))) {
$body["lunParameters"] = @{}
$lunParameters = @{}
If ($PSBoundParameters.ContainsKey('Size')) {
$lunParameters["size"] = $($Size)
}
If ($PSBoundParameters.ContainsKey('fastVPParameters')) {
$lunParameters["fastVPParameters"] = @{}
$fastVPParam = @{}
$fastVPParam['tieringPolicy'] = $fastVPParameters
$lunParameters["fastVPParameters"] = $fastVPParam
}
If ($PSBoundParameters.ContainsKey('isCompressionEnabled')) {
$lunParameters["isCompressionEnabled"] = $isCompressionEnabled
}
If ($PSBoundParameters.ContainsKey('host')) {
$lunParameters["hostAccess"] = @()
$hostAccess = @()
foreach ($h in $host) {
$blockHostAccessParam = @{}
$blockHostAccessParam['host'] = @{}
$HostParam = @{}
$HostParam['id'] = $h
$blockHostAccessParam['host'] = $HostParam
$blockHostAccessParam['accessMask'] = $accessMask
$hostAccess += $blockHostAccessParam
}
If ($PSBoundParameters.ContainsKey('append')) {
foreach ($h in $Object.hostAccess) {
if (-not ($hostAccess.host.id -contains $h.host.id)) {
$blockHostAccessParam = @{}
$blockHostAccessParam['host'] = @{}
$HostParam = @{}
$HostParam['id'] = $h.host.id
$blockHostAccessParam['host'] = $HostParam
$blockHostAccessParam['accessMask'] = $h.accessMask
$hostAccess += $blockHostAccessParam
}
}
} else {
Write-Warning -Message 'The existing host access parameters will be overwritten by the new settings. It could result to data unavailibility. Use the -Append parameter to add the new settings to the existing configuration.'
}
$lunParameters["hostAccess"] = $hostAccess
}
$body["lunParameters"] = $lunParameters
}
#snapScheduleParameters
If ($snapSchedule) {
$body["snapScheduleParameters"] = @{}
$snapScheduleParameters = @{}
$snapScheduleParam = @{}
$snapScheduleParam["id"] ="$($snapSchedule)"
$snapScheduleParameters["snapSchedule"] = $snapScheduleParam
$snapScheduleParameters["isSnapSchedulePaused"]= "$($isSnapSchedulePaused)"
$body["snapScheduleParameters"] = $snapScheduleParameters
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$UnitystorageResource.id
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityVMwareLUN -Session $Sess -ID $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityESXi.ps1
|
Get-UnityESXi.ps1
|
Function Get-UnityESXi {
<#
.SYNOPSIS
View details about ESXi configuration on the system.
.DESCRIPTION
View details about ESXi configuration on the system.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityESXi
Retrieve information about all ESXi hosts
.EXAMPLE
Get-UnityESXi -Name 'ESXi01'
Retrieves information about ESXi named 'ESXi01'
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'ESXi Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'ESXi ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/hostContainer/instances' #URI
$Filter = 'type eq 1'
$TypeName = 'UnityHostContainer'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName] -Filter $Filter
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnitySnapSchedule.ps1
|
Remove-UnitySnapSchedule.ps1
|
Function Remove-UnitySnapSchedule {
<#
.SYNOPSIS
Delete a snapshot schedule.
.DESCRIPTION
Delete a snapshot schedule.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
ID of the snapshot Schedule or snapshot Schedule Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnitySnapSchedule -ID 'snapSch_11'
Delete the snapshot schedule with ID 'snapSch_11'
.EXAMPLE
Get-UnitySnapSchedule | Remove-UnitySnapSchedule
Delete all existing snapshots schedule.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'snapshot ID or snapshot Object')]
[Object[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/snapSchedule/<id>'
$Type = 'Snapshot Schedule'
$TypeName = 'UnitySnapSchedule'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = Get-UnitySnapSchedule -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnitySnapSchedule -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE'
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityNFSServer.ps1
|
Get-UnityNFSServer.ps1
|
Function Get-UnityNFSServer {
<#
.SYNOPSIS
Information about the NFS Servers in the storage system.
.DESCRIPTION
Information about the NFS Servers in the storage system.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityNFSServer
Retrieve informations about all the NFS Servers.
#>
[CmdletBinding(DefaultParameterSetName="ID")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'NFS Server ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/nfsServer/instances'
$TypeName = 'UnityNfsServer'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnitySnapSchedule.ps1
|
Get-UnitySnapSchedule.ps1
|
Function Get-UnitySnapSchedule {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve informations about snapshots schedule.
.DESCRIPTION
Queries the EMC Unity array to retrieve informations about snapshots schedule.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnitySnapSchedule
Retrieve information about Snap
.EXAMPLE
Get-UnitySnapSchedule -Name 'SNAP01'
Retrieves information about snapshot named SNAP01
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Snap Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Snap ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/snapSchedule/instances' #URI
$TypeName = 'UnitySnapSchedule'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityStorageResource.ps1
|
Get-UnityStorageResource.ps1
|
Function Get-UnitystorageResource {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve informations about UnitystorageResource.
.DESCRIPTION
Querries the EMC Unity array to retrieve informations about UnitystorageResource.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.PARAMETER Type
Specifies the storage ressource type. Might be:
- lun
- vmwareiscsi
- vmwarefs
.EXAMPLE
Get-UnitystorageResource
Retrieve informations about all the storage ressources
.EXAMPLE
Get-UnitystorageResource -Name 'DATASTORE01'
Retrieves informations about storage ressource named DATASTORE01
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Storage Resource Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Storage Resource ID')]
[String[]]$ID,
[Parameter(Mandatory = $false,HelpMessage = 'Storage ressource type')]
[ValidateSet('lun','vmwareiscsi','vmwarefs')]
[String]$Type
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/storageResource/instances' #URI for the ressource (example: /api/types/lun/instances)
$TypeName = 'UnitystorageResource'
Switch ($Type) {
'lun' {$Filter = 'type eq 8'}
'vmwareiscsi' {$Filter = 'type eq 4'}
'vmwarefs' {$Filter = 'type eq 3'}
}
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName] -Filter $Filter
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityIpInterface.ps1
|
Get-UnityIpInterface.ps1
|
Function Get-UnityIpInterface {
<#
.SYNOPSIS
Information about network interfaces in the storage system.
.DESCRIPTION
Information about network interfaces in the storage system.
Network interfaces enable and control access between the system, network, and configured hosts.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityIpInterface
Retrieve informations about all the management interface.
#>
[CmdletBinding(DefaultParameterSetName="ID")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'IP Interface ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/ipInterface/instances' #URI for the ressource (example: /api/types/lun/instances)
$TypeName = 'UnityIpInterface'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnitySystem.ps1
|
Get-UnitySystem.ps1
|
Function Get-UnitySystem {
<#
.SYNOPSIS
Information about general settings for the storage system.
.DESCRIPTION
Information about general settings for the storage system.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnitySystem
Retrieve informations about all the arrays with an active session.
.EXAMPLE
Get-UnitySystem -Name 'UnityVSA'
Retrieves informations about an array named 'UnityVSA'
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Unity Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Unity ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/system/instances' #URI for the ressource (example: /api/types/lun/instances)
$TypeName = 'UnitySystem'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityPool.ps1
|
Get-UnityPool.ps1
|
Function Get-UnityPool {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve informations about pool.
.DESCRIPTION
Queries the EMC Unity array to retrieve informations about pool.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityPool
Retrieve information about pool
.EXAMPLE
Get-UnityPool -Name 'POOL01'
Retrieves information about pool named POOL01
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Pool Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Pool ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/pool/instances' #URI
$TypeName = 'UnityPool'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityFileInterface.ps1
|
Get-UnityFileInterface.ps1
|
Function Get-UnityFileInterface {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve informations about File Interfaces.
.DESCRIPTION
Queries the EMC Unity array to retrieve informations about File Interfaces.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityFileInterface
Retrieve information about all interfaces
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'File Interface Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'File Interface ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/fileInterface/instances' #URI
$TypeName = 'UnityFileInterface'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnityVMwareLUN.ps1
|
Remove-UnityVMwareLUN.ps1
|
Function Remove-UnityVMwareLUN {
<#
.SYNOPSIS
Delete a VMware block LUN.
.DESCRIPTION
Delete a VMware block LUN.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
VMware LUN ID or Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnityVMwareLUN -ID 'sv_15'
Delete the VMware block LUN ID 'sv_15'
.EXAMPLE
Get-UnityVMwareLUN -ID 'sv_15' | Remove-UnityVMwareLUN
Delete the VMware block LUN ID 'sv_15'. The LUN's informations are provided by the Get-UnityVMwareLUN through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'VMware LUN ID or Object')]
$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/storageResource/<id>'
$Type = 'VMware LUN'
$TypeName = 'UnityLUN'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityVMwareLUN -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityVMwareLUN -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
$UnityStorageResource = Get-UnitystorageResource -Session $sess | Where-Object {($_.Name -like $ObjectName) -and ($_.luns.id -like $ObjectID)}
#Building the URL
$FinalURI = $URI -replace '<id>',$UnityStorageResource.id
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE'
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityCifsServer.ps1
|
Get-UnityCifsServer.ps1
|
Function Get-UnityCIFSServer {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve informations about CIFS Server.
.DESCRIPTION
Queries the EMC Unity array to retrieve informations about CIFS Server.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityCIFSServer
Retrieve information about all CIFS Server
.EXAMPLE
Get-UnityCIFSServer -Name 'SERVER01'
Retrieves information about CIFS server named SERVER01
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'CIFS Server Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'CIFS Server ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/cifsServer/instances' #URI
$TypeName = 'UnityCifsServer'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Enable-UnityFastCache.ps1
|
Enable-UnityFastCache.ps1
|
Function Enable-UnityFastCache {
<#
.SYNOPSIS
Enable FAST Cache.
.DESCRIPTION
Enable FAST Cache using specified disk group and number of disks and if specified, Enable FAST Cache on all existing pools.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER diskgroup
Specify the disk group ID to include in the FAST Cache.
.PARAMETER numberOfDisks
Specify the number of disks to include in the FAST Cache.
.PARAMETER enableOnAllPools
Specify whether FAST Cache is enabled on all existing pools.
.EXAMPLE
Enable-UnityFastCache -diskgroup 'DG_1' -numberOfDisks 2
Enable Fast Cache with 2 disk from the disk group 'DG_1'
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#FastCache enable parameters
[Parameter(Mandatory = $true,HelpMessage = 'Disk group ID from which to take disks for FAST cache')]
[string]$diskgroup,
[Parameter(Mandatory = $true,HelpMessage = 'Number of disks')]
[int]$numberOfDisks,
[Parameter(Mandatory = $false,HelpMessage = 'Enable FAST Cache for all existing pools')]
[switch]$enableOnAllPools
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
# Creation of the body hash
$body = @{}
#diskgroup
$body['diskgroup'] = @{}
$diskgroupParam = @{}
$diskgroupParam['id'] = $diskgroup
$body['diskgroup'] = $diskgroupParam
#numberOfDisks
$body['numberOfDisks'] = $numberOfDisks
# enableOnAllPools
If ($PSBoundParameters.ContainsKey('enableOnAllPools')) {
$body["enableOnAllPools"] = $true
}
#Building the URI
$URI = 'https://'+$sess.Server+'/api/instances/fastCache/0/action/enable?timeout=0' #run async
Write-Verbose "URI: $URI"
#Sending the request
If ($pscmdlet.ShouldProcess($($Sess.Server),"Enable Fast Cache")) {
$request = Send-UnityRequest -uri $URI -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq '202') {
Write-Host "Fast Cache is currently enabling"
}
} else {
Write-Information -MessageData "You are no longer connected to EMC Unity array: $($Sess.Server)"
}
}
}
End {}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/New-UnityvCenter.ps1
|
New-UnityvCenter.ps1
|
Function New-UnityvCenter {
<#
.SYNOPSIS
Add the vCenter credentials and optionally discovers any ESXi host managed by that vCenter.
.DESCRIPTION
Discover vCenter servers on the network and optionnaly create a host configuration for multiple ESXi hosts managed by a single vCenter server. For any discovered vCenters, you can enable or disable access for any ESXi host managed by the vCenter. After you associate a vCenter server configuration with a VMware datastore, the datastore is available to any ESXi hosts associated with the vCenter host configuration.
The vCenter credentials are stored in the storage system.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Address
FQDN or IP address of the VMware vCenter.
.PARAMETER Username
Specifies the username used to access the VMware vCenter.
.PARAMETER Password
Specifies the password used to access the VMware vCenter.
.PARAMETER Description
Specifies the description of the VMware vCenter server.
.PARAMETER ImportHosts
Specifies if hosts are automatically imported.
.EXAMPLE
New-UnityvCenter -Address 'vcenter.example.com' -Username 'admin' -Password 'Password123#' -ImportHosts
Import a vCenter and all the associated ESXi hosts.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#vCenter
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'The IP address of the vCenter server')]
[String[]]$Address,
[Parameter(Mandatory = $true,HelpMessage = 'The user name to access vCenter server')]
[string]$Username,
[Parameter(Mandatory = $true,HelpMessage = 'The password to connect to vCenter server')]
[String]$Password,
[Parameter(Mandatory = $false,HelpMessage = 'Description of the vCenter server')]
[String]$Description,
[Parameter(Mandatory = $false,HelpMessage = 'Specifies if hosts are automatically imported')]
[Switch]$ImportHosts
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/types/hostContainer/instances'
$Type = 'vCenter'
$StatusCode = 201
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
#### REQUEST BODY
Foreach ($a in $Address) {
$recommendation = Get-UnityHostContainerReco -Session $Sess -Address $a -Username $Username -Password $Password
# Creation of the body hash
$body = @{}
# serviceType parameter
$body["serviceType"] = "$($recommendation.type)"
# targetName parameter
$body["targetName"] = "$($recommendation.containerName)"
# targetAddress parameter
$body["targetAddress"] = "$a"
# username parameter
$body["username"] = "$Username"
# password parameter
$body["password"] = "$Password"
If ($PSBoundParameters.ContainsKey('description')) {
$body["description"] = $Description
}
If ($PSBoundParameters.ContainsKey('ImportHosts')) {
$body["potentialHosts"] = $recommendation.potentialHosts | Where-Object {$_.importOption -ne 2}
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
##Building the URL
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Create $Type $a")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
Write-Verbose "Request status code: $($request.StatusCode)"
If ($request.StatusCode -eq $StatusCode) {
#Formating the result. Converting it from JSON to a Powershell object
$results = ($request.content | ConvertFrom-Json).content
Write-Verbose "$Type with the ID $($results.id) has been created"
Get-UnityvCenter -Session $Sess -ID $results.id
} # End If ($request.StatusCode -eq $StatusCode)
} # End If ($Sess.TestConnection())
} # End Foreach
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityHostIPPort.ps1
|
Set-UnityHostIPPort.ps1
|
Function Set-UnityHostIPPort {
<#
.SYNOPSIS
Modify a host IP Port configuration.
.DESCRIPTION
Modify a host IP Port configuration.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for Host IP Port confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Set-UnityHostIPPort -ID 'HostNetworkAddress_47' -address '192.168.0.1'
Change the IP of the host.
.EXAMPLE
Get-UnityHostIPPort -ID 'HostNetworkAddress_47' | Set-UnityHostIPPort -address '192.168.0.1'
Gives the role 'operator' to the Host IP Port 'Host'. The Host's information are provided by the Get-UnityHostIPPort through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#Host IP Port ID or Object
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Host IP Port ID or Object')]
$ID,
#IP address or network name of the port.
[Parameter(Mandatory = $false,HelpMessage = 'IP address or network name of the port.')]
[string]$address,
#(Applies to IPV4 only.) Subnet mask for the IP address, if any.
[Parameter(Mandatory = $false,HelpMessage = '(Applies to IPV4 only.) Subnet mask for the IP address, if any.')]
[string]$netmask,
#(Applies to IPV6 only.) Subnet mask length.
[Parameter(Mandatory = $false,HelpMessage = '(Applies to IPV6 only.) Subnet mask length.')]
[string]$v6PrefixLength,
#(Applies to NFS access only.) Indicates whether the port should be ignored when storage access is granted to the host
[Parameter(Mandatory = $false,HelpMessage = '(Applies to NFS access only.) Indicates whether the port should be ignored when storage access is granted to the host')]
[bool]$isIgnored
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/hostIPPort/<id>/action/modify'
$Type = 'Host IP Port'
$TypeName = 'UnityHostIPPort'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityHostIPPort -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityHostIPPort -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
If ($PSBoundParameters.ContainsKey('address')) {
$body["address"] = $address
}
If ($PSBoundParameters.ContainsKey('netmask')) {
$body["netmask"] = $netmask
}
If ($PSBoundParameters.ContainsKey('v6PrefixLength')) {
$body["v6PrefixLength"] = $v6PrefixLength
}
If ($PSBoundParameters.ContainsKey('isIgnored')) {
$body["isIgnored"] = $isIgnored
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityHostIPPort -Session $Sess -id $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/New-UnityMgmtInterface.ps1
|
New-UnityMgmtInterface.ps1
|
Function New-UnityMgmtInterface {
<#
.SYNOPSIS
Create a new network interface for managing the array.
.DESCRIPTION
Create a new network interface for managing the array.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ipAddress
IPv4 or IPv6 address for the interface.
.PARAMETER netmask
IPv4 netmask for the interface, if the interface uses an IPv4 address.
.PARAMETER v6PrefixLength
Prefix length in bits for IPv6 address.
.PARAMETER gateway
IPv4 or IPv6 gateway address for the interface.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
New-UnityMgmtInterface -ipAddress '192.168.0.1' -netmask '255.255.255.0' -gateway '192.168.0.254'
Create a new network interface for managing the array.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 1,HelpMessage = 'IPv4 or IPv6 address for the interface.')]
[string]$ipAddress,
[Parameter(Mandatory = $false,HelpMessage = 'IPv4 netmask for the interface, if the interface uses an IPv4 address.')]
[string]$netmask,
[Parameter(Mandatory = $false,HelpMessage = 'Prefix length in bits for IPv6 address.')]
[String[]]$v6PrefixLength,
[Parameter(Mandatory = $true,Position = 1,HelpMessage = 'IPv4 or IPv6 gateway address for the interface.')]
[string]$gateway
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
## Variables
$URI = '/api/types/mgmtInterface/instances?timeout=0' #run async
$Type = 'Management Interface'
$StatusCode = 202
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
#### REQUEST BODY
#Creation of the body hash
$body = @{}
#Body arguments
$body["ipAddress"] = $ipAddress
$body["gateway"] = $gateway
If ($PSBoundParameters.ContainsKey('netmask')) {
$body["netmask"] = "$($netmask)"
}
If ($PSBoundParameters.ContainsKey('v6PrefixLength')) {
$body["v6PrefixLength"] = "$($v6PrefixLength)"
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
##Building the URL
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
Write-Warning -Message 'You might be disconnected from the old interface'
If ($pscmdlet.ShouldProcess($Sess.Name,"Create $Type $ipAddress")) {
$request = Send-UnityRequest -uri $URI -Session $Sess -Method 'POST' -Body $Body
}
Write-Verbose "Request status code: $($request.StatusCode)"
If ($request.StatusCode -eq $StatusCode) {
Write-Host "Management interface is creating asynchronously."
} # End If ($request.StatusCode -eq $StatusCode)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnityHost.ps1
|
Remove-UnityHost.ps1
|
Function Remove-UnityHost {
<#
.SYNOPSIS
Delete host.
.DESCRIPTION
Delete host.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
Host ID or Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnityHost -ID 'host_5'
Delete the host with ID 'host_5'
.EXAMPLE
Get-UnityHost -ID 'host_5' | Remove-UnityHost
Delete the host with ID 'host_5'. host informations are provided by the Get-UnityHost through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Host ID or Object')]
$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/host/<id>'
$Type = 'Host'
$TypeName = 'UnityHost'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityHost -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityHost -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE'
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityAlertConfig.ps1
|
Set-UnityAlertConfig.ps1
|
Function Set-UnityAlertConfig {
<#
.SYNOPSIS
Modifies Alert Config.
.DESCRIPTION
Modifies Alert Config.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
Config ALert ID or Object.
.PARAMETER alertLocale
Language in which the system sends email alerts.
.PARAMETER isThresholdAlertsEnabled
Whether pool space usage related alerts will be sent.
.PARAMETER minEmailNotificationSeverity
Minimum severity level for email alerts.
.PARAMETER minSNMPTrapNotificationSeverity
Minimum severity level for SNMP trap alerts.
.PARAMETER destinationEmails
List of emails to receive alert notifications.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Set-UnityAlertConfig -destinationEmails 'mail@example.com'
Modifies the default Alert Config
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'ID of the Alert Config')]
[String[]]$ID = '0',
[Parameter(Mandatory = $false,HelpMessage = 'Language in which the system sends email alerts.')]
[LocaleEnum]$alertLocale,
[Parameter(Mandatory = $false,HelpMessage = 'Whether pool space usage related alerts will be sent.')]
[bool]$isThresholdAlertsEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Minimum severity level for email alerts.')]
[SeverityEnum]$minEmailNotificationSeverity,
[Parameter(Mandatory = $false,HelpMessage = 'Minimum severity level for SNMP trap alerts.')]
[SeverityEnum]$minSNMPTrapNotificationSeverity,
[Parameter(Mandatory = $false,HelpMessage = 'List of emails to receive alert notifications.')]
[string[]]$destinationEmails
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/alertConfig/<id>/action/modify'
$Type = 'Alert Config'
$TypeName = 'UnityAlertConfig'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityAlertConfig -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityAlertConfig -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
If ($PSBoundParameters.ContainsKey('alertLocale')) {
$body["alertLocale"] = $alertLocale
}
If ($PSBoundParameters.ContainsKey('isThresholdAlertsEnabled')) {
$body["isThresholdAlertsEnabled"] = $isThresholdAlertsEnabled
}
If ($PSBoundParameters.ContainsKey('minEmailNotificationSeverity')) {
$body["minEmailNotificationSeverity"] = $minEmailNotificationSeverity
}
If ($PSBoundParameters.ContainsKey('minSNMPTrapNotificationSeverity')) {
$body["minSNMPTrapNotificationSeverity"] = $minSNMPTrapNotificationSeverity
}
If ($PSBoundParameters.ContainsKey('destinationEmails')) {
$body['destinationEmails'] = @()
Foreach ($email in $destinationEmails) {
$body["destinationEmails"] += $email
}
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityAlertConfig -Session $Sess -id $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnitySystem.ps1
|
Set-UnitySystem.ps1
|
Function Set-UnitySystem {
<#
.SYNOPSIS
Modifies Unity storage system.
.DESCRIPTION
Modifies Unity storage system.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
ID or Object.
.PARAMETER name
New name of the Unity
.PARAMETER isUpgradeCompleted
Indicates whether to manually mark an upgrade process completed.
.PARAMETER isEulaAccepted
Indicates whether to accept the End User License Agreement (EULA).
.PARAMETER isAutoFailbackEnabled
Indicates whether to enable the automatic failback of NAS servers in the system.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Set-UnitySystem -ID '0' -isEULAAccepted $True
Accept the EULA.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'ID or Object')]
[String]$ID = '0',
[Parameter(Mandatory = $false,HelpMessage = 'New name of the Unity')]
[String]$name,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether to manually mark an upgrade process completed')]
[bool]$isUpgradeCompleted,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether to accept the End User License Agreement (EULA)')]
[bool]$isEulaAccepted,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether to enable the automatic failback of NAS servers in the system')]
[bool]$isAutoFailbackEnabled
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/system/<id>/action/modify'
$Type = 'System'
$TypeName = 'UnitySystem'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
# Determine input and convert to object if necessary
Switch ($ID.GetType().Name)
{
"String" {
$Object = get-UnitySystem -Session $Sess -ID $ID
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($ID.GetType().Name)"
$ObjectID = $ID.id
If ($Object = Get-UnitySystem -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
If ($PSBoundParameters.ContainsKey('name')) {
$body["name"] = $name
}
If ($PSBoundParameters.ContainsKey('isUpgradeCompleted')) {
$body["isUpgradeCompleted"] = $isUpgradeCompleted
}
If ($PSBoundParameters.ContainsKey('isEulaAccepted')) {
$body["isEulaAccepted"] = $isEulaAccepted
}
If ($PSBoundParameters.ContainsKey('isAutoFailbackEnabled')) {
$body["isAutoFailbackEnabled"] = $isAutoFailbackEnabled
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnitySystem -Session $Sess -id $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/New-UnityFileInterface.ps1
|
New-UnityFileInterface.ps1
|
Function New-UnityFileInterface {
<#
.SYNOPSIS
Creates a File Interface.
.DESCRIPTION
Creates a File Interface.
These interfaces control access to Windows (CIFS) and UNIX/Linux (NFS) file storage.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER nasServer
ID of the NAS server to which the network interface belongs
.PARAMETER ipPort
Physical port or link aggregation on the storage processor on which the interface is running
.PARAMETER ipAddress
IP address of the network interface
.PARAMETER netmask
IPv4 netmask for the network interface, if it uses an IPv4 address
.PARAMETER v6PrefixLength
IPv6 prefix length for the interface, if it uses an IPv6 address
.PARAMETER gateway
IPv4 or IPv6 gateway address for the network interface
.PARAMETER vlanId
LAN identifier for the interface. The interface uses the identifier to accept packets that have matching VLAN tags. Values are 1 - 4094.
.PARAMETER isPreferred
Sets the current IP interface as preferred for associated for file-based storage and unsets the previous one
.PARAMETER role
Role of NAS server network interface
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
New-UnityFileInterface -ipPort spa_eth0 -nasServer nas_6 -ipAddress 192.168.0.1 -netmask 255.255.255.0 -gateway 192.168.0.254
Create interface on the ethernet port 'spa_eth0' associated to the NAS server 'nas_6'
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 1,HelpMessage = 'ID of the NAS server to which the network interface belongs')]
$nasServer,
[Parameter(Mandatory = $true,HelpMessage = 'Physical port or link aggregation on the storage processor on which the interface is running')]
$ipPort,
[Parameter(Mandatory = $true,HelpMessage = 'IP address of the network interface')]
[ipaddress]$ipAddress,
[Parameter(Mandatory = $false,HelpMessage = 'IPv4 netmask for the network interface, if it uses an IPv4 address')]
[ipaddress]$netmask,
[Parameter(Mandatory = $false,HelpMessage = 'IPv6 prefix length for the interface, if it uses an IPv6 address')]
[String]$v6PrefixLength,
[Parameter(Mandatory = $false,HelpMessage = 'IPv4 or IPv6 gateway address for the network interface')]
[ipaddress]$gateway,
[Parameter(Mandatory = $false,HelpMessage = ' VLAN identifier for the interface. The interface uses the identifier to accept packets that have matching VLAN tags. Values are 1 - 4094.')]
[int]$vlanId,
[Parameter(Mandatory = $false,HelpMessage = 'Sets the current IP interface as preferred for associated for file-based storage and unsets the previous one')]
[bool]$isPreferred,
[Parameter(Mandatory = $false,HelpMessage = 'Role of NAS server network interface')]
[FileInterfaceRoleEnum]$role
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/types/fileInterface/instances'
$Type = 'File Interface'
$StatusCode = 201
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
# Creation of the body hash
$body = @{}
# nasServer argument
$body["nasServer"] = @{}
$nasServerArg = @{}
$nasServerArg["id"] = "$($nasServer)"
$body["nasServer"] = $nasServerArg
# ipPort argument
$body["ipPort"] = @{}
$ipPortArg = @{}
$ipPortArg["id"] = "$($ipPort)"
$body["ipPort"] = $ipPortArg
# ipAddress argument
$body["ipAddress"] = "$ipAddress"
If ($PSBoundParameters.ContainsKey('netmask')) {
$body["netmask"] = "$netmask"
}
If ($PSBoundParameters.ContainsKey('v6PrefixLength')) {
$body["v6PrefixLength"] = "$v6PrefixLength"
}
If ($PSBoundParameters.ContainsKey('gateway')) {
$body["gateway"] = "$gateway"
}
If ($PSBoundParameters.ContainsKey('vlanId')) {
$body["vlanId"] = $vlanId
}
If ($PSBoundParameters.ContainsKey('isPreferred')) {
$body["isPreferred"] = $isPreferred
}
If ($PSBoundParameters.ContainsKey('role')) {
$body["role"] = "$role"
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
##Building the URL
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Create $Type on $ipPort")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
Write-Verbose "Request status code: $($request.StatusCode)"
If ($request.StatusCode -eq $StatusCode) {
#Formating the result. Converting it from JSON to a Powershell object
$results = ($request.content | ConvertFrom-Json).content
Write-Verbose "$Type with the ID $($results.id) has been created"
#Executing Get-UnityUser with the ID of the new user
Get-UnityFileInterface -Session $Sess -ID $results.id
} # End If ($request.StatusCode -eq $StatusCode)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityNasServer.ps1
|
Set-UnityNasServer.ps1
|
Function Set-UnityNASServer {
<#
.SYNOPSIS
Modifies NAS Server parameters.
.DESCRIPTION
Modifies NAS Server parameters.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER ID
NAS Server ID or Object
.PARAMETER Name
Specifies the NAS server new name.
NAS server names can contain alphanumeric characters, a single dash, and a single underscore.
Server names cannot contain spaces or begin or end with a dash.
You can create NAS server names in four parts that are separated by periods (example: aa.bb.cc.dd).
Names can contain up to 255 characters, but the first part of the name (before the first period) is limited to 15 characters.
.PARAMETER homeSP
Specifies the parent SP for the NAS server.
.PARAMETER Pool
Specifies the ID of the storage pool for the NAS server.
.PARAMETER isReplicationDestination
Replication destination settings for the NAS server.
When this option is set to yes, only mandatory parameters may be included.
All other optional parameters will be inherited from the source NAS server.
Valid values are $true or $false (default).
.PARAMETER UnixDirectoryService
Directory Service used for querying identity information for Unix (such as UIDs, GIDs, net groups). Valid values are:
- NIS
- LDAP
- None (Default)
.PARAMETER isMultiProtocolEnabled
Indicates whether multiprotocol sharing mode is enabled. Value is $true or $false (default).
.PARAMETER allowUnmappedUser
Use this flag to mandatorily disable access in case of any user mapping failure. Valide value are $true or $false (default).
.PARAMETER defaultUnixUser
Default Unix user name that grants file access in the multiprotocol sharing mode.
This user name is used when the corresponding Unix/Linux user name is not found by the mapping mechanism.
.PARAMETER defaultWindowsUser
Default Windows user name that grants file access in the multiprotocol sharing mode.
This user name is used when the corresponding Windows user name is not found by the mapping mechanism.
.EXAMPLE
Set-UnityNasServer -Name 'NAS01' -Description 'Modified description'
Change the description of the NAS Server named NAS01
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#NasServer
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'NAS Server ID or Object')]
[String[]]$ID,
#NasServer Set parameters
[Parameter(Mandatory = $false,HelpMessage = 'New Name of the Nas Server')]
[String]$Name,
[Parameter(Mandatory = $false,HelpMessage = 'Storage processor ID on which the NAS server will run')]
$homeSP,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether the NAS server is a replication destination')]
[bool]$isReplicationDestination,
[Parameter(Mandatory = $false,HelpMessage = 'Directory Service used for quering identity information for Unix')]
[NasServerUnixDirectoryServiceEnum]$UnixDirectoryService,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether multiprotocol sharing mode is enabled')]
[bool]$isMultiProtocolEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Use this flag to mandatorily disable access in case of any user mapping failure')]
[bool]$allowUnmappedUser,
[Parameter(Mandatory = $false,HelpMessage = 'Default Unix user name used for granting access in case of Windows to Unix user mapping failure')]
$defaultUnixUser,
[Parameter(Mandatory = $false,HelpMessage = 'Default Windows user name used for granting access in case of Unix to Windows user mapping failure. When empty, access in such case is denied')]
$defaultWindowsUser
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/nasServer/<id>/action/modify'
$Type = 'NAS Server'
$TypeName = 'UnityNasServer'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityNASServer -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityNASServer -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
# Creation of the body hash
$body = @{}
# Name parameter
If ($Name) {
$body["name"] = "$($Name)"
}
# homeSP parameter
If ($PSBoundParameters.ContainsKey('homeSP')) {
$body["homeSP"] = @{}
$homeSPParameters = @{}
$homeSPParameters["id"] = "$($homeSP)"
$body["homeSP"] = $homeSPParameters
}
If ($PSBoundParameters.ContainsKey('isReplicationDestination')) {
$body["isReplicationDestination"] = $isReplicationDestination
}
If ($PSBoundParameters.ContainsKey('UnixDirectoryService')) {
$body["currentUnixDirectoryService"] = $($UnixDirectoryService)
}
If ($PSBoundParameters.ContainsKey('isMultiProtocolEnabled')) {
$body["isMultiProtocolEnabled"] = $isMultiProtocolEnabled
}
If ($PSBoundParameters.ContainsKey('allowUnmappedUser')) {
$body["allowUnmappedUser"] = $allowUnmappedUser
}
If ($PSBoundParameters.ContainsKey('defaultUnixUser')) {
$body["defaultUnixUser"] = $defaultUnixUser
}
If ($PSBoundParameters.ContainsKey('defaultWindowsUser')) {
$body["defaultWindowsUser"] = $defaultWindowsUser
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityNASServer -Session $Sess -id $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityVMwareLUN.ps1
|
Get-UnityVMwareLUN.ps1
|
Function Get-UnityVMwareLUN {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve informations about VMware block LUN.
.DESCRIPTION
Querries the EMC Unity array to retrieve informations about VMware block LUN.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityVMwareLUN
Retrieve information about all VMware block LUN
.EXAMPLE
Get-UnityVMwareLUN -Name 'DATASTORE01'
Retrieves information about VMware block LUN named DATASTORE01
#>
[CmdletBinding(DefaultParameterSetName="ID")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'VMware LUN Name')]
[String[]]$Name='*',
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'VMware LUN ID')]
[String[]]$ID='*'
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$ResultCollection = @()
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
$StorageResource = Get-UnitystorageResource -Session $Sess -Type 'vmwareiscsi'
If ($StorageResource) {
$ResultCollection += Get-UnityLUNResource -Session $Sess -ID $StorageResource.luns.id
}
}
}
}
Process {
#Filter results
If ($ResultCollection) {
Switch ($PsCmdlet.ParameterSetName) {
'Name' {
Foreach ($N in $Name) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Return result(s) with the filter: $($N)"
Write-Output $ResultCollection | Where-Object {$_.Name -like $N}
Write-Debug -Message "[$($MyInvocation.MyCommand)] Found $($ResultCollection.Count) item(s)"
}
}
'ID' {
Foreach ($I in $ID) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Return result(s) with the filter: $($I)"
Write-Output $ResultCollection | Where-Object {$_.Id -like $I}
Write-Debug -Message "[$($MyInvocation.MyCommand)] Found $($ResultCollection.Count) item(s)"
}
}
} #End Switch
} # End If ($ResultCollection)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnitySession.ps1
|
Get-UnitySession.ps1
|
Function Get-UnitySession {
<#
.SYNOPSIS
List the existing sessions.
.DESCRIPTION
List the existing sessions.
.NOTES
Written by Erwan Quelin under MIT licence
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Server
IP or FQDN of the Unity array.
.EXAMPLE
Get-UnitySession
List all the existing sessions.
.EXAMPLE
Get-UnitySession -Server 192.168.0.1'
Lists sessions connected the the array '192.168.0.1'
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity IP or FQDN')]
[String]$Server
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
}
Process {
If ($Server) {
Write-Verbose "Return DefaultUnitySession matching the Server IP or FQDN: $Server"
return $global:DefaultUnitySession | where-object {$_.Server -match $Server}
} else {
Write-Verbose "Return DefaultUnitySessionclear"
return $global:DefaultUnitySession
}
}
End {}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityAlert.ps1
|
Get-UnityAlert.ps1
|
Function Get-UnityAlert {
<#
.SYNOPSIS
Information about alerts generated by the storage system.
.DESCRIPTION
Information about alerts generated by the storage system.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityAlert
Retrieve Information about alerts generated by the storage system.
#>
[CmdletBinding(DefaultParameterSetName="ID")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Alert ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/alert/instances' #URI for the ressource (example: /api/types/lun/instances)
$TypeName = 'UnityAlert'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityIscsiPortal.ps1
|
Get-UnityIscsiPortal.ps1
|
Function Get-UnityIscsiPortal {
<#
.SYNOPSIS
Information about the iSCSI portals in the storage system.
.DESCRIPTION
Information about the iSCSI portals in the storage system.
iSCSI portals are used for controlling access to iSCSI storage
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityIscsiPortal
Retrieve informations about all the iSCSI portal.
#>
[CmdletBinding(DefaultParameterSetName="ID")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'iSCSI portal ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/iscsiPortal/instances' #URI for the ressource (example: /api/types/lun/instances)
$TypeName = 'UnityIscsiPortal'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityAlertConfig.ps1
|
Get-UnityAlertConfig.ps1
|
Function Get-UnityAlertConfig {
<#
.SYNOPSIS
Information about the Alert Configs in the storage system.
.DESCRIPTION
Information about the Alert Configs in the storage system.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityAlertConfig
Retrieve informations about all the Alert Configs.
#>
[CmdletBinding(DefaultParameterSetName="ID")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Alert Config ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/alertConfig/instances'
$TypeName = 'UnityAlertConfig'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnityIscsiPortal.ps1
|
Remove-UnityIscsiPortal.ps1
|
Function Remove-UnityiSCSIPortal {
<#
.SYNOPSIS
Delete an iSCSI network portal.
.DESCRIPTION
Delete an iSCSI network portal.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
iSCSI network portal ID or Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnityIscsiPortal -ID 'if_6'
Delete the iSCSI network portal with ID 'if_6'
.EXAMPLE
Get-UnityIscsiPortal -ID 'if_6' | Remove-UnityIscsiPortal
Delete the iSCSI network portal with ID 'if_6'. iSCSI network portal informations are provided by the Get-UnityIscsiPortal through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'iSCSI network portal ID or Object')]
$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/iscsiPortal/<id>'
$Type = 'iSCSI Portal'
$TypeName = 'UnityIscsiPortal'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityiSCSIPortal -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityiSCSIPortal -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE'
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityLicense.ps1
|
Get-UnityLicense.ps1
|
Function Get-UnityLicense {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve informations about licenses.
.DESCRIPTION
Querries the EMC Unity array to retrieve informations about licenses.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityLicense
Retrieve information about all licenses
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Licence Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Licence ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/license/instances' #URI for the ressource (example: /api/types/lun/instances)
$TypeName = 'UnityLicense'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/New-UnitySnap.ps1
|
New-UnitySnap.ps1
|
Function New-UnitySnap {
<#
.SYNOPSIS
Creates a new snapshot.
.DESCRIPTION
Creates a new snapshot.
Creating a snapshot creates a new point-in-time view of a block or file resource associated with the point-in-time at which the snapshot was taken.
Immediately after being created, a snapshot consumes almost no space for the pool as it still shares all of its blocks with the primary block or file resource.
However as new data is written to the parent resource, redirects occur as discussed previously, and the snapshot begins to consume pool space that is not also associated with the current production version of the parent resource.
Once a snapshot is created, it is available to perform snapshot operations on such as restoring, copying, attaching/detaching, or deleting.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER storageRessouce
Storage resource ID or object.
.PARAMETER Name
Name for the new snapshot.
.PARAMETER Description
Description for new snapshot.
.PARAMETER isAutoDelete
Auto delete policy for new snapshot.
.PARAMETER retentionDuration
How long (in seconds) to keep the snapshot (Can be specified only if auto delete is set to false).
.PARAMETER isReadOnly
Indicates if the new snapshot should be read-only.
.PARAMETER filesystemAccessType
Indicates if the new snapshot should be created with checkpoint or protocol type access (file system or VMware NFS datastore snapshots only).
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
New-UnitySnap -StorageResource 'res_41' -Name 'snap01'
Create snap named 'snap01' from sorage resource ID 'res_41'
.EXAMPLE
Get-UnityVMwareNFS -Name 'VOLUME01' | New-UnitySnap
Create a snapshot of the VMware NFS volume.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#UnitySnap
[Parameter(Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Storage resource ID or object.')]
[Object[]]$storageResource,
[Parameter(Mandatory = $false,HelpMessage = 'Name for the new snapshot')]
[String]$name,
[Parameter(Mandatory = $false,HelpMessage = 'Description for new snapshot')]
[String]$Description,
[Parameter(Mandatory = $false,HelpMessage = 'Auto delete policy for new snapshot')]
[bool]$isAutoDelete,
[Parameter(Mandatory = $false,HelpMessage = 'How long to keep the snapshot (Can be specified only if auto delete is set to false).')]
[uint64]$retentionDuration,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates if the new snapshot should be read-only.')]
[bool]$isReadOnly,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates if the new snapshot should be created with checkpoint or protocol type access (file system or VMware NFS datastore snapshots only)')]
[FilesystemSnapAccessTypeEnum]$filesystemAccessType
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
## Variables
$URI = '/api/types/snap/instances'
$Type = 'snap'
$StatusCode = 201
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
Foreach ($sr in $storageResource) {
# Determine input and convert to object if necessary
Write-Verbose "Input object type is $($sr.GetType().Name)"
Switch ($sr.GetType().Name)
{
"UnityFilesystem" {
$ObjectID = $sr.StorageResource.id
}
"UnityLUN" {
$ObjectID = $sr.StorageResource.id
}
"String" {
If ($Object = Get-UnitystorageResource -Session $Sess -ID $sr -ErrorAction SilentlyContinue) {
$ObjectID = $Object.id
} else {
Throw "This Storage Resource does not exist"
}
}
}
#### REQUEST BODY
# Creation of the body hash
$body = @{}
$body["storageResource"] = @{}
$storageResourceParameter = @{}
$storageResourceParameter["id"] = $ObjectID
$body["storageResource"] = $storageResourceParameter
If ($PSBoundParameters.ContainsKey('name')) {
$body["name"] = $name
}
If ($PSBoundParameters.ContainsKey('description')) {
$body["description"] = $description
}
If ($PSBoundParameters.ContainsKey('isAutoDelete')) {
$body["isAutoDelete"] = $isAutoDelete
}
If ($PSBoundParameters.ContainsKey('retentionDuration')) {
$body["retentionDuration"] = $retentionDuration
}
If ($PSBoundParameters.ContainsKey('isReadOnly')) {
$body["isReadOnly"] = $isReadOnly
}
If ($PSBoundParameters.ContainsKey('filesystemAccessType')) {
$body["filesystemAccessType"] = $filesystemAccessType
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
##Building the URL
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Create $Type on storage resource ID $ObjectID")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
Write-Verbose "Request status code: $($request.StatusCode)"
If ($request.StatusCode -eq $StatusCode) {
#Formating the result. Converting it from JSON to a Powershell object
$results = ($request.content | ConvertFrom-Json).content
Write-Verbose "$Type with the ID $($results.id) has been created"
Get-UnitySnap -Session $Sess -ID $results.id
} # End If ($request.StatusCode -eq $StatusCode)
} # End If ($Sess.TestConnection())
} # End Foreach
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Test-UnityUIAlert.ps1
|
Test-UnityUIAlert.ps1
|
Function Test-UnityUIAlert {
<#
.SYNOPSIS
Test GUI alert notification by sending a test alert to all open CEM GUIs.
.DESCRIPTION
Test GUI alert notification by sending a test alert to all open CEM GUIs.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
ID or Object of a Alert Config..
.EXAMPLE
Test-UnityUIAlert
Test GUI alert notification by sending a test alert to all open CEM GUIs.
#>
[CmdletBinding(DefaultParameterSetName="Refresh")]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'ID or Object of Alert Config')]
[String[]]$ID = '0'
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/alertConfig/<id>/action/testUIAlert'
$Type = 'Alert'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityAlertConfig -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityAlertConfig -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST'
If ($request.StatusCode -eq $StatusCode) {
Write-Host "$Type send to the UI"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityVMwareNFS.ps1
|
Set-UnityVMwareNFS.ps1
|
Function Set-UnityVMwareNFS {
<#
.SYNOPSIS
Modifies filesystem parameters.
.DESCRIPTION
Modifies filesystem parameters.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Name
New Name of the filesystem
.PARAMETER Description
Filesystem Description
.PARAMETER snapSchedule
ID of a protection schedule to apply to the filesystem
.PARAMETER isSnapSchedulePaused
Is assigned snapshot schedule is paused ? (Default is false)
.PARAMETER Size
Filesystem Size
.PARAMETER hostIOSize
Typical write I/O size from the host to the file system
.PARAMETER tieringPolicy
Filesystem tiering policy
.PARAMETER defaultAccess
Default access level for all hosts accessing the VMware NFS LUN.
.PARAMETER noAccessHosts
Hosts with no access to the VMware NFS LUN or its snapshots, as defined by the host resource type.
.PARAMETER readOnlyHosts
Hosts with read-only access to the VMware NFS LUN and its snapshots, as defined by the host resource type.
.PARAMETER readWriteHosts
Hosts with read-write access to the VMware NFS LUN and its snapshots, as defined by the host resource type.
.PARAMETER rootAccessHosts
Hosts with root access to the VMware NFS LUN and its snapshots, as defined by the host resource type.
.PARAMETER Append
Append Hosts access to existing configuration
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Set-UnityVMwareNFS -ID 'fs_1' -Description 'Modified description'
Change the description of the VMware NFS LUN named FS01
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#SetFilesystem
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'VMware NFS LUN ID or Object')]
[String[]]$ID,
[Parameter(Mandatory = $false,HelpMessage = 'Filesystem Description')]
[String]$Description,
[Parameter(Mandatory = $false,HelpMessage = 'ID of a protection schedule to apply to the VMware NFS LUN')]
[String]$snapSchedule,
[Parameter(Mandatory = $false,HelpMessage = 'Is assigned snapshot schedule is paused ? (Default is false)')]
[bool]$isSnapSchedulePaused = $false,
#fsParameters
[Parameter(Mandatory = $false,HelpMessage = 'VMware NFS LUN Size in Bytes')]
[uint64]$Size,
[Parameter(Mandatory = $false,HelpMessage = 'Typical write I/O size from the host to the file system')]
[HostIOSizeEnum]$hostIOSize,
##fastVPParameters
[Parameter(Mandatory = $false,HelpMessage = 'VMware NFS LUN tiering policy')]
[TieringPolicyEnum]$tieringPolicy,
#$nfsShareParameters
[Parameter(Mandatory = $false,HelpMessage = 'Default access level for all hosts accessing the VMware NFS LUN.')]
[NFSShareDefaultAccessEnum]$defaultAccess,
[Parameter(Mandatory = $false,HelpMessage = 'Hosts with no access to the VMware NFS LUN or its snapshots.')]
[string[]]$noAccessHosts,
[Parameter(Mandatory = $false,HelpMessage = 'Hosts with read-only access to the VMware NFS LUN and its snapshots.')]
[string[]]$readOnlyHosts,
[Parameter(Mandatory = $false,HelpMessage = 'Hosts with read-write access to the VMware NFS LUN and its snapshots.')]
[string[]]$readWriteHosts,
[Parameter(Mandatory = $false,HelpMessage = 'Hosts with root access to the VMware NFS LUN and its snapshots.')]
[string[]]$rootAccessHosts,
[Parameter(Mandatory = $false,HelpMessage = 'Append Hosts access to existing configuration')]
[Switch]$append
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/storageResource/<id>/action/modifyVmwareNfs'
$Type = 'VMware NFS LUN'
$TypeName = 'UnityFilesystem'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityVMwareNFS -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityVMwareNFS -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
$UnitystorageResource = Get-UnitystorageResource -Session $sess | Where-Object {($_.filesystem.id -like $ObjectID)}
$NFSShare = Get-UnityNFSShare -Session $Sess -ID $Object.NfsShare.id
#### REQUEST BODY
# Creation of the body hash
$body = @{}
# Description parameter
If ($Description) {
$body["description"] = "$($Description)"
}
If (($PSBoundParameters.ContainsKey('Size')) -or ($PSBoundParameters.ContainsKey('hostIOSize')) -or ($PSBoundParameters.ContainsKey('tieringPolicy'))) {
# fsParameters parameter
$body["fsParameters"] = @{}
$fsParameters = @{}
# Size
If ($PSBoundParameters.ContainsKey('Size')) {
$fsParameters["Size"] = $Size
}
# hostIOSize
If ($PSBoundParameters.ContainsKey('hostIOSize')) {
$fsParameters["hostIOSize"] = $hostIOSize
}
# fastVPParameters
If ($PSBoundParameters.ContainsKey('tieringPolicy')) {
$fastVPParameters = @{}
$fastVPParameters['tieringPolicy'] = $tieringPolicy
$fsParameters["fastVPParameters"] = $fastVPParameters
}
$body["fsParameters"] = $fsParameters
}
#$nfsShareParameters
$nfsShareParameters = @{}
If ($PSBoundParameters.ContainsKey('defaultAccess')) {
$nfsShareParameters["defaultAccess"] = $defaultAccess
}
If ($PSBoundParameters.ContainsKey('noAccessHosts')) {
$nfsShareParameters["noAccessHosts"] = @()
foreach ($h in $noAccessHosts) {
$HostParam = @{}
$HostParam['id'] = $h
$nfsShareParameters["noAccessHosts"] += $HostParam
}
If ($append) {
foreach ($h in $NFSShare.noAccessHosts) {
$nfsShareParameters["noAccessHosts"] += $h
}
}
}
If ($PSBoundParameters.ContainsKey('readOnlyHosts')) {
$nfsShareParameters["readOnlyHosts"] = @()
foreach ($h in $readOnlyHosts) {
$HostParam = @{}
$HostParam['id'] = $h
$nfsShareParameters["readOnlyHosts"] += $HostParam
}
If ($append) {
foreach ($h in $NFSShare.readOnlyHosts) {
$nfsShareParameters["readOnlyHosts"] += $h
}
}
}
If ($PSBoundParameters.ContainsKey('readWriteHosts')) {
$nfsShareParameters["readWriteHosts"] = @()
foreach ($h in $readWriteHosts) {
$HostParam = @{}
$HostParam['id'] = $h
$nfsShareParameters["readWriteHosts"] += $HostParam
}
If ($append) {
foreach ($h in $NFSShare.readWriteHosts) {
$nfsShareParameters["readWriteHosts"] += $h
}
}
}
If ($PSBoundParameters.ContainsKey('rootAccessHosts')) {
$nfsShareParameters["rootAccessHosts"] = @()
foreach ($h in $rootAccessHosts) {
$HostParam = @{}
$HostParam['id'] = $h
$nfsShareParameters["rootAccessHosts"] += $HostParam
}
If ($append) {
foreach ($h in $NFSShare.rootAccessHosts) {
$nfsShareParameters["rootAccessHosts"] += $h
}
}
}
If ($nfsShareParameters.count) {
$body["nfsShareParameters"] = @{}
$body["nfsShareParameters"] = $nfsShareParameters
}
#snapScheduleParameters
If ($snapSchedule) {
$body["snapScheduleParameters"] = @{}
$snapScheduleParameters = @{}
$snapScheduleParam = @{}
$snapScheduleParam["id"] ="$($snapSchedule)"
$snapScheduleParameters["snapSchedule"] = $snapScheduleParam
$snapScheduleParameters["isSnapSchedulePaused"]= "$($isSnapSchedulePaused)"
$body["snapScheduleParameters"] = $snapScheduleParameters
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$UnitystorageResource.id
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityVMwareNFS -Session $Sess -ID $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnityNFSServer.ps1
|
Remove-UnityNFSServer.ps1
|
Function Remove-UnityNFSServer {
<#
.SYNOPSIS
Delete NFS Server.
.DESCRIPTION
Delete NFS Server.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
NFS Server ID or Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnityNFSServer -ID 'default'
Delete the NFS Server with ID 'default'
.EXAMPLE
Get-UnityNFSServer -Name 'default' | Remove-UnityNFSServer
Delete the NFS Server with ID 'default'. NFS Server informations are provided by the Get-UnityNFSServer through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'NFS Server ID or Object')]
$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/nfsServer/<id>'
$Type = 'NFS Server'
$TypeName = 'UnityNFSServer'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityNFSServer -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityNFSServer -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE'
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityNTPServer.ps1
|
Get-UnityNTPServer.ps1
|
Function Get-UnityNTPServer {
<#
.SYNOPSIS
Information about NTP Servers.
.DESCRIPTION
Information about NTP Servers.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.EXAMPLE
Get-UnityNTPServer
Retrieve informations about the NTP Servers.
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true})
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/ntpServer/instances' #URI for the ressource (example: /api/types/lun/instances)
$TypeName = 'UnityNTPServer'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Test-UnityUCAlert.ps1
|
Test-UnityUCAlert.ps1
|
Function Test-UnityUCAlert {
<#
.SYNOPSIS
Test Unisphere Central alert notification by sending a test alert to a Unisphere Central destination.
.DESCRIPTION
Test Unisphere Central alert notification by sending a test alert to a Unisphere Central destination.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
ID or Object of a Alert Config..
.EXAMPLE
Test-UnityUCAlert
Test Unisphere Central alert notification by sending a test alert to a Unisphere Central destination.
#>
[CmdletBinding(DefaultParameterSetName="Refresh")]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'ID or Object of Alert Config')]
[String[]]$ID = '0'
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/alertConfig/<id>/action/testUCAlert'
$Type = 'Alert'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityAlertConfig -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityAlertConfig -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST'
If ($request.StatusCode -eq $StatusCode) {
Write-Host "$Type send to the Unisphere Central"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityHostIPPort.ps1
|
Get-UnityHostIPPort.ps1
|
Function Get-UnityHostIPPort {
<#
.SYNOPSIS
View details about host IP Port configuration on the system.
.DESCRIPTION
View details about host IP Port configuration on the system.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityHostIPPort
Retrieve information about all hosts
.EXAMPLE
Get-UnityHostIPPort -ID 'ESX01'
Retrieves information about host IP Port named 'ESX01'
#>
[CmdletBinding(DefaultParameterSetName="ID")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Host IP Port ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/hostIPPort/instances' #URI
$TypeName = 'UnityHostIPPort'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityNTPServer.ps1
|
Set-UnityNTPServer.ps1
|
Function Set-UnityNTPServer {
<#
.SYNOPSIS
Modifies NTP Servers parameters.
.DESCRIPTION
Modifies NTP Servers parameters.
You can configure a total of four NTP server addresses for the system.
All NTP server addresses are grouped into a single NTP server record.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Addresses
List of NTP server IP addresses.
.PARAMETER rebootPrivilege
Indicates whether a system reboot of the NTP server is required for setting the system time.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Set-UnityNTPServer -Addresses '192.168.0.1','192.168.0.2'
replace the exsting address list for this NTP server with this new list.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'List of NTP server IP addresses.')]
[String[]]$Addresses,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether a system reboot of the NTP server is required for setting the system time.')]
[RebootPrivilegeEnum]$rebootPrivilege = 'No_Reboot_Allowed'
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/ntpServer/<id>/action/modify'
$Type = 'NTP Server'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
$Object = Get-UnityNTPServer -Session $Sess
$ObjectID = $Object.id
#### REQUEST BODY
# Creation of the body hash
$body = @{}
$body['addresses'] = @()
Foreach ($Addresse in $Addresses) {
$body["addresses"] += $Addresse
}
$body["rebootPrivilege"] = $rebootPrivilege
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityPool -Session $Sess -id $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/New-UnityNFSShare.ps1
|
New-UnityNFSShare.ps1
|
Function New-UnityNFSShare {
<#
.SYNOPSIS
Creates NFS share.
.DESCRIPTION
Creates NFS share.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Filesystem
Specify Filesystem ID
.PARAMETER Path
Local path to a location within a file system.
.PARAMETER Name
Name of the NFS share unique to NAS server
.PARAMETER description
NFS share description
.PARAMETER isReadOnly
Indicates whether the NFS share is read-only. Values are:
- true - NFS share is read-only.
- false - NFS share is read-write.
.PARAMETER defaultAccess
Default access level for all hosts accessing the NFS share.
.PARAMETER minSecurity
Minimal security level that must be provided by a client to mount the NFS share.
.PARAMETER noAccessHosts
Hosts with no access to the NFS share or its snapshots, as defined by the host resource type.
.PARAMETER readOnlyHosts
Hosts with read-only access to the NFS share and its snapshots, as defined by the host resource type.
.PARAMETER readWriteHosts
Hosts with read-write access to the NFS share and its snapshots, as defined by the host resource type.
.PARAMETER rootAccessHosts
Hosts with root access to the NFS share and its snapshots, as defined by the host resource type.
.EXAMPLE
New-UnityNFSShare -Filesystem fs_17 -Path / -Name 'NFSSHARE01' -rootAccessHosts Host_20
Create a new NFS Share named 'NFSSHARE01'
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#SetFilesystem
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Filesystem ID')]
[String[]]$Filesystem,
#nfsShareCreate
[Parameter(Mandatory = $true,HelpMessage = 'Local path to a location within a file system')]
[String]$Path,
[Parameter(Mandatory = $true,HelpMessage = 'Name of the NFS share unique to NAS server')]
[String]$Name,
#$nfsShareParameters
[Parameter(Mandatory = $false,HelpMessage = 'NFS share description')]
[String]$description,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether the NFS share is read-only')]
[bool]$isReadOnly = $false,
[Parameter(Mandatory = $false,HelpMessage = 'Default access level for all hosts accessing the NFS share.')]
[NFSShareDefaultAccessEnum]$defaultAccess,
[Parameter(Mandatory = $false,HelpMessage = 'Minimal security level that must be provided by a client to mount the NFS share.')]
[NFSShareSecurityEnum]$minSecurity,
[Parameter(Mandatory = $false,HelpMessage = 'Hosts with no access to the NFS share or its snapshots.')]
[string[]]$noAccessHosts,
[Parameter(Mandatory = $false,HelpMessage = 'Hosts with read-only access to the NFS share and its snapshots.')]
[string[]]$readOnlyHosts,
[Parameter(Mandatory = $false,HelpMessage = 'Hosts with read-write access to the NFS share and its snapshots.')]
[string[]]$readWriteHosts,
[Parameter(Mandatory = $false,HelpMessage = 'Hosts with root access to the NFS share and its snapshots.')]
[string[]]$rootAccessHosts
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
## Variables
$URI = '/api/instances/storageResource/<id>/action/modifyFilesystem'
$Type = 'Share NFS'
$TypeName = 'UnityFilesystem'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($fs in $Filesystem) {
# Determine input and convert to UnityFilesystem object
Switch ($fs.GetType().Name)
{
"String" {
$Object = get-UnityFilesystem -Session $Sess -ID $fs
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $fs.id
If ($Object = Get-UnityFilesystem -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
#### REQUEST BODY
$UnityStorageRessource = Get-UnitystorageResource -Session $sess | ? {($_.Name -like $ObjectName) -and ($_.filesystem.id -like $ObjectID)}
# Creation of the body hash
$body = @{}
$body["nfsShareCreate"] = @()
$nfsShareCreateParameters = @{}
# path
$nfsShareCreateParameters["path"] = "$($path)"
# name
$nfsShareCreateParameters["name"] = "$($name)"
#$nfsShareParameters
$nfsShareCreateParameters["nfsShareParameters"] = @{}
$nfsShareParameters = @{}
If ($PSBoundParameters.ContainsKey('description')) {
$nfsShareParameters["description"] = "$($description)"
}
$nfsShareParameters["isReadOnly"] = $isReadOnly
If ($PSBoundParameters.ContainsKey('defaultAccess')) {
$nfsShareParameters["defaultAccess"] = $defaultAccess
}
If ($PSBoundParameters.ContainsKey('minSecurity')) {
$nfsShareParameters["minSecurity"] = $minSecurity
}
If ($PSBoundParameters.ContainsKey('noAccessHosts')) {
$nfsShareParameters["noAccessHosts"] = @()
foreach ($h in $noAccessHosts) {
$HostParam = @{}
$HostParam['id'] = $h
$nfsShareParameters["noAccessHosts"] += $HostParam
}
}
If ($PSBoundParameters.ContainsKey('readOnlyHosts')) {
$nfsShareParameters["readOnlyHosts"] = @()
foreach ($h in $readOnlyHosts) {
$HostParam = @{}
$HostParam['id'] = $h
$nfsShareParameters["readOnlyHosts"] += $HostParam
}
}
If ($PSBoundParameters.ContainsKey('readWriteHosts')) {
$nfsShareParameters["readWriteHosts"] = @()
foreach ($h in $readWriteHosts) {
$HostParam = @{}
$HostParam['id'] = $h
$nfsShareParameters["readWriteHosts"] += $HostParam
}
}
If ($PSBoundParameters.ContainsKey('rootAccessHosts')) {
$nfsShareParameters["rootAccessHosts"] = @()
foreach ($h in $rootAccessHosts) {
$HostParam = @{}
$HostParam['id'] = $h
$nfsShareParameters["rootAccessHosts"] += $HostParam
}
}
$nfsShareCreateParameters["nfsShareParameters"] = $nfsShareParameters
$body["nfsShareCreate"] += $nfsShareCreateParameters
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$URI = $URI -replace '<id>',$UnityStorageRessource.id
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Create $Type $name")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityNFSShare -Session $Sess -Name $name
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($fs in $Filesystem)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/New-UnityCifsServer.ps1
|
New-UnityCifsServer.ps1
|
Function New-UnityCIFSServer {
<#
.SYNOPSIS
Create an SMB/CIFS server.
.DESCRIPTION
Create an SMB/CIFS server.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER nasServer
ID of the NAS server to which the SMB server belongs.
.PARAMETER netbiosName
Computer name of the SMB server in Windows network.
.PARAMETER name
User friendly, descriptive name of SMB server.
.PARAMETER description
Description of the SMB server.
.PARAMETER domain
Domain name where SMB server is registered in Active Directory, if applicable.
.PARAMETER organizationalUnit
LDAP organizational unit of SMB server in Active Directory, if applicable.
.PARAMETER domainUsername
Active Directory domain user name.
.PARAMETER domainPassword
Active Directory domain password.
.PARAMETER reuseComputerAccount
Reuse existing SMB server account in the Active Directory.
.PARAMETER workgroup
Standalone SMB server workgroup.
.PARAMETER localAdminPassword
Standalone SMB server administrator password.
.PARAMETER interfaces
List of file IP interfaces that service CIFS protocol of SMB server.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
New-UnityCIFSServer -Name CIFS01 -nasServer 'nas_6' -domain 'example.com' -domainUsername 'administrator' -domainPassword 'Password#123' -interfaces 'if_1'
Create CIFS Server named 'CIFS01'
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High',DefaultParameterSetName="AD")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,Position = 1,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'User friendly, descriptive name of SMB server')]
[String[]]$Name,
[Parameter(Mandatory = $true,HelpMessage = 'ID of the NAS server to which the SMB server belongs')]
[String]$nasServer,
[Parameter(Mandatory = $false,HelpMessage = 'Computer name of the SMB server in Windows network')]
[String]$netbiosName,
[Parameter(Mandatory = $false,HelpMessage = 'Description of the SMB server')]
[String]$Description,
[Parameter(Mandatory = $false,ParameterSetName="AD",HelpMessage = 'Domain name where SMB server is registered in Active Directory, if applicable.')]
[String]$domain,
[Parameter(Mandatory = $false,ParameterSetName="AD",HelpMessage = 'LDAP organizational unit of SMB server in Active Directory, if applicable')]
[String]$organizationalUnit,
[Parameter(Mandatory = $false,ParameterSetName="AD",HelpMessage = 'Active Directory domain user name')]
[String]$domainUsername,
[Parameter(Mandatory = $false,ParameterSetName="AD",HelpMessage = 'Active Directory domain password')]
[String]$domainPassword,
[Parameter(Mandatory = $false,ParameterSetName="AD",HelpMessage = 'Reuse existing SMB server account in the Active Directory')]
[Bool]$reuseComputerAccount,
[Parameter(Mandatory = $false,ParameterSetName="Workgroup",HelpMessage = 'Standalone SMB server workgroup name')]
[String]$workgroup,
[Parameter(Mandatory = $false,ParameterSetName="Workgroup",HelpMessage = 'Is Snapshot Harvest Enabled')]
[String]$localAdminPassword,
[Parameter(Mandatory = $false,HelpMessage = 'List of file IP interfaces that service CIFS protocol of SMB server')]
[String[]]$interfaces
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
## Variables
$URI = '/api/types/cifsServer/instances'
$Type = 'Server CIFS'
$StatusCode = 201
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
Foreach ($n in $Name) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
# nasServer argument
$body["nasServer"] = @{}
$nasServerArg = @{}
$nasServerArg["id"] = "$($nasServer)"
$body["nasServer"] = $nasServerArg
# netbiosName argument
If ($PSBoundParameters.ContainsKey('netbiosName')) {
$body["netbiosName"] = "$($netbiosName)"
}
# Name argument
If ($PSBoundParameters.ContainsKey('Name')) {
$body["name"] = "$($name)"
}
# Description argument
If ($PSBoundParameters.ContainsKey('description')) {
$body["description"] = "$($description)"
}
# domain argument
If ($PSBoundParameters.ContainsKey('domain')) {
$body["domain"] = "$($domain)"
}
# organizationalUnit argument
If ($PSBoundParameters.ContainsKey('organizationalUnit')) {
$body["organizationalUnit"] = "$($organizationalUnit)"
}
# domainUsername argument
If ($PSBoundParameters.ContainsKey('domainUsername')) {
$body["domainUsername"] = "$($domainUsername)"
}
# domainPassword argument
If ($PSBoundParameters.ContainsKey('domainPassword')) {
$body["domainPassword"] = "$($domainPassword)"
}
# reuseComputerAccount argument
If ($PSBoundParameters.ContainsKey('reuseComputerAccount')) {
$body["reuseComputerAccount"] = $reuseComputerAccount
}
# workgroup argument
If ($PSBoundParameters.ContainsKey('workgroup')) {
$body["workgroup"] = "$($workgroup)"
}
# localAdminPassword argument
If ($PSBoundParameters.ContainsKey('localAdminPassword')) {
$body["localAdminPassword"] = "$($localAdminPassword)"
}
#interfaces argument
If ($PSBoundParameters.ContainsKey('interfaces')) {
$body['interfaces'] = @()
Foreach ($int in $interfaces) {
$ÎntArgument = @{}
$ÎntArgument['id'] = "$($int)"
$body["interfaces"] += $ÎntArgument
}
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
##Building the URL
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Create $Type $n")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
Write-Verbose "Request status code: $($request.StatusCode)"
If ($request.StatusCode -eq $StatusCode) {
#Formating the result. Converting it from JSON to a Powershell object
$results = ($request.content | ConvertFrom-Json).content
Write-Verbose "$Type with the ID $($results.id) has been created"
Get-UnityCifsServer -Session $Sess -ID $results.id
} # End If ($request.StatusCode -eq $StatusCode)
} # End If ($Sess.TestConnection())
} # End Foreach
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnityPool.ps1
|
Remove-UnityPool.ps1
|
Function Remove-UnityPool {
<#
.SYNOPSIS
Delete a pool.
.DESCRIPTION
Delete a pool.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
ID of the pool or Pool Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnityPool -ID 'pool_12'
Delete the pool with ID 'pool_12'
.EXAMPLE
Get-UnityPool -ID 'pool_10' | Remove-UnityPool
Delete the pool with ID 'pool_10'. The pool's informations are provided by the Get-UnityPool through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Pool ID or Pool Object')]
$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/pool/<id>'
$Type = 'Pool'
$TypeName = 'UnityPool'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityPool -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityPool -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE'
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityvCenter.ps1
|
Set-UnityvCenter.ps1
|
Function Set-UnityvCenter {
<#
.SYNOPSIS
Modifies an existing vCenter and optionally discovers any ESXi host managed by that vCenter.
.DESCRIPTION
Modifies vCenter servers on the network and optionnaly create a host configuration for multiple ESXi hosts managed by a single vCenter server.
You can't modify vCenter parameters and import hosts in the same command.
For any discovered vCenters, you can enable or disable access for any ESXi host managed by the vCenter.
After you associate a vCenter server configuration with a VMware datastore, the datastore is available to any ESXi hosts associated with the vCenter host configuration.
The vCenter credentials are stored in the storage system.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
vCenter ID or Object.
.PARAMETER NewAddress
The new FQDN or IP address of the VMware vCenter.
.PARAMETER NewUsername
Specifies the new username used to access the VMware vCenter.
.PARAMETER NewPassword
Specifies the new password used to access the VMware vCenter.
.PARAMETER Description
Specifies the new description of the VMware vCenter server.
.PARAMETER Username
Specifies the new username used to access the VMware vCenter.
.PARAMETER Password
Specifies the new password used to access the VMware vCenter.
.PARAMETER ImportHosts
Specifies if hosts are automatically imported.
.EXAMPLE
Set-UnityvCenter -ID 'mss_1' -Description 'New description'
Change the description of the vCenter.
.EXAMPLE
Set-UnityvCenter -ID 'mss_1' -Username 'administrator@vsphere.local' -Password 'Password#123' -ImportHosts
Import hosts associated to the vCenter.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High',DefaultParameterSetName="Set")]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#vCenter
[Parameter(Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'vCenter ID or Object')]
$ID,
[Parameter(Mandatory = $false,ParameterSetName="Set",HelpMessage = 'The new FQDN or IP address of the vCenter server')]
[String]$NewAddress,
[Parameter(Mandatory = $false,ParameterSetName="Set",HelpMessage = 'The new user name to access vCenter server')]
[string]$NewUsername,
[Parameter(Mandatory = $false,ParameterSetName="Set",HelpMessage = 'The new password to connect to vCenter server')]
[String]$NewPassword,
[Parameter(Mandatory = $false,ParameterSetName="Set",HelpMessage = 'The new description of the vCenter server')]
[String]$Description,
[Parameter(Mandatory = $true,ParameterSetName="ImportHosts",HelpMessage = 'The user name to access vCenter server')]
[string]$Username,
[Parameter(Mandatory = $true,ParameterSetName="ImportHosts",HelpMessage = 'The password to connect to vCenter server')]
[String]$Password,
[Parameter(Mandatory = $true,ParameterSetName="ImportHosts",HelpMessage = 'Specifies if hosts are automatically imported')]
[Switch]$ImportHosts
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
Foreach ($I in $ID) {
Write-Verbose "Processing ID: $I"
# Determine input and convert to an object
Write-Verbose "Input object type is $($I.GetType().Name)"
Switch ($I.GetType().Name)
{
"String" {
$vCenterServer = get-UnityvCenter -Session $Sess -ID $I
$vCenterServerID = $vCenterServer.id
}
"UnityHostContainer" {
$vCenterServer = $I
$vCenterServerID = $ID.id
}
}
If ($vCenterServerID) {
# Creation of the body hash
$body = @{}
Switch ($PsCmdlet.ParameterSetName) {
'Set' {
If ($PSBoundParameters.ContainsKey('NewAddress')) {
$body["targetAddress"] = $NewAddress
}
If ($PSBoundParameters.ContainsKey('description')) {
$body["description"] = $Description
}
If ($PSBoundParameters.ContainsKey('NewUsername')) {
$body["username"] = $NewUsername
}
If ($PSBoundParameters.ContainsKey('NewPassword')) {
$body["password"] = $NewPassword
}
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
#Building the URI
$URI = 'https://'+$sess.Server+'/api/instances/hostContainer/'+$vCenterServerID+'/action/modify'
Write-Verbose "URI: $URI"
#Sending the request
If ($pscmdlet.ShouldProcess($vCenterServerID,"Modify vCenter Server")) {
$request = Send-UnityRequest -uri $URI -Session $Sess -Method 'POST' -Body $Body
}
Write-Verbose "Request status code: $($request.StatusCode)"
If (($request.StatusCode -eq '200') -or ($request.StatusCode -eq '204')) {
Write-Verbose "vCenter $vCenterServerID has been modified"
#Executing Get-UnityUser with the ID of the Set user
Get-UnityvCenter -Session $Sess -ID $vCenterServerID
}
} else {
Write-Warning "You are no longer connected to EMC Unity array: $($Sess.Server)"
}
}
'ImportHosts' {
$recommendation = Get-UnityHostContainerReco -Session $Sess -Address $vCenterServer.address -Username $Username -Password $Password
Foreach ($Host in $recommendation.potentialHosts) {
$body["potentialHosts"] = @()
$body["potentialHosts"] += $Host
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
#Building the URI
$URI = 'https://'+$sess.Server+'/api/instances/hostContainer/'+$vCenterServerID+'/action/modify'
Write-Verbose "URI: $URI"
#Sending the request
If ($pscmdlet.ShouldProcess($host.servername,"Add host")) {
$request = Send-UnityRequest -uri $URI -Session $Sess -Method 'POST' -Body $Body
}
} else {
Write-Warning "You are no longer connected to EMC Unity array: $($Sess.Server)"
}
}
#Executing Get-UnityUser with the ID of the Set user
Get-UnityvCenter -Session $Sess -ID $vCenterServerID
}
}
} else {
Write-Verbose "vCenter Server does not exist on the array $($sess.Name)"
}
}
}
}
End {}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityBasicSystemInfo.ps1
|
Get-UnityBasicSystemInfo.ps1
|
Function Get-UnityBasicSystemInfo {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve basic informations about arrays.
.DESCRIPTION
Queries the EMC Unity array to retrieve basic informations about arrays.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityBasicSystemInfo
Retrieve basic information about arrays
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'LUN Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'LUN ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/basicSystemInfo/instances' #URI for the ressource (example: /api/types/lun/instances)
$TypeName = 'UnityBasicSystemInfo'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnityCifsServer.ps1
|
Remove-UnityCifsServer.ps1
|
Function Remove-UnityCIFSServer {
<#
.SYNOPSIS
Delete a Cifs Server.
.DESCRIPTION
Delete a Cifs Server.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
CIFS Server ID or Object.
.PARAMETER skipUnjoin
Keep SMB server account unjoined in Active Directory after deletion.
.PARAMETER domainUsername
Username for unjoin.
.PARAMETER domainPassword
Password for unjoin.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnityCifsServer -ID 'cifs_1'
Delete the Cifs Server with ID 'cifs_1'
.EXAMPLE
Get-UnityCifsServer -Name 'CIFS01' | Remove-UnityCifsServer
Delete the Cifs Server named 'CIFS01'. The Cifs Server's informations are provided by the Get-UnityNasServer through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'CIFS Server ID or Object')]
$ID,
[Parameter(Mandatory = $false,HelpMessage = 'Keep SMB server account unjoined in Active Directory after deletion')]
[bool]$skipUnjoin,
[Parameter(Mandatory = $false,HelpMessage = 'Username for unjoin')]
[String]$domainUsername,
[Parameter(Mandatory = $false,HelpMessage = 'Password for unjoin')]
[String]$domainPassword
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/cifsServer/<id>'
$Type = 'CIFS Server'
$TypeName = 'UnityCifsServer'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
If ($PSBoundParameters.ContainsKey('skipUnjoin')) {
$body["skipUnjoin"] = $skipUnjoin
}
If ($PSBoundParameters.ContainsKey('domainUsername')) {
$body["domainUsername"] = "$domainUsername"
}
If ($PSBoundParameters.ContainsKey('domainPassword')) {
$body["domainPassword"] = $domainPassword
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityCIFSServer -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityCIFSServer -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE' -Body $body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityLUN.ps1
|
Get-UnityLUN.ps1
|
Function Get-UnityLUN {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve informations about block LUN.
.DESCRIPTION
Querries the EMC Unity array to retrieve informations about block LUN.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityLUN
Retrieve information about all block LUN
.EXAMPLE
Get-UnityLUN -Name 'LUN01'
Retrieves information about block LUN named LUN01
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'LUN Name')]
[String[]]$Name='*',
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'LUN ID')]
[String[]]$ID='*'
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$ResultCollection = @()
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
$StorageResource = Get-UnityStorageResource -Session $Sess -Type 'lun'
If ($StorageResource) {
$ResultCollection += Get-UnityLUNResource -Session $Sess -ID $StorageResource.luns.id
}
}
}
}
Process {
#Filter results
If ($ResultCollection) {
Switch ($PsCmdlet.ParameterSetName) {
'Name' {
Foreach ($N in $Name) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Return result(s) with the filter: $($N)"
Write-Output $ResultCollection | Where-Object {$_.Name -like $N}
Write-Debug -Message "[$($MyInvocation.MyCommand)] Found $($ResultCollection.Count) item(s)"
}
}
'ID' {
Foreach ($I in $ID) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Return result(s) with the filter: $($I)"
Write-Output $ResultCollection | Where-Object {$_.Id -like $I}
Write-Debug -Message "[$($MyInvocation.MyCommand)] Found $($ResultCollection.Count) item(s)"
}
}
} #End Switch
} # End If ($ResultCollection)
} # End Process
End {}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityMgmtInterfaceSettings.ps1
|
Set-UnityMgmtInterfaceSettings.ps1
|
Function Set-UnityMgmtInterfaceSettings {
<#
.SYNOPSIS
Modifies global management interfaces settings.
.DESCRIPTION
Modifies global management interfaces settings.
It is not allowed to set both IPv4 and IPv6 to Disabled at the same time, in any sequence.
It is not allowed to set both IPv4 and IPv6 to Auto in one request.
IPv4 or IPv6 may be set to Auto only if the other class IP address already exists, either set as a static IP address or obtained in Auto mode.
The Static can be set only implicitly by creating the mgmtInterface object.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER v4ConfigMode
New IPv4 config mode. Might be:
- Disabled: Management access is disabled.
- Static: Management interface address is set manually with Set-UnityMgmtInterface.
- Auto: Management interface address is configured by DHCP.
.PARAMETER v6ConfigMode
New IPv6 config mode. Might be:
- Disabled: Management access is disabled.
- Static: Management interface address is set manually with Set-UnityMgmtInterface.
- Auto: Management interface address is configured by SLAAC.
.EXAMPLE
Set-UnityMgmtInterfaceSettings -Addresses '192.168.0.1','192.168.0.2'
replace the exsting address list for this DNS server with this new list.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,HelpMessage = 'New IPv4 config mode. Might be Disabled, Static or Auto')]
[InterfaceConfigModeEnum]$v4ConfigMode,
[Parameter(Mandatory = $false,HelpMessage = 'New IPv6 config mode. Might be Disabled, Static or Auto')]
[InterfaceConfigModeEnum]$v6ConfigMode
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/mgmtInterfaceSettings/0/action/modify'
$Type = 'Global management interfaces settings'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
If ($PSBoundParameters.ContainsKey('v4ConfigMode')) {
$body["v4ConfigMode"] = $v4ConfigMode
}
If ($PSBoundParameters.ContainsKey('v6ConfigMode')) {
$body["v6ConfigMode"] = $v6ConfigMode
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URI
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityMgmtInterfaceSettings -Session $Sess
} # End If ($ObjectID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityItem.ps1
|
Get-UnityItem.ps1
|
Function Get-UnityItem {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve informations about a specific item.
.DESCRIPTION
Querries the EMC Unity array to retrieve informations about a specific item. You need to provide the URI of the item (ex: /api/types/pool/instances) with the parameter -URI.
By default, the response is a powershell object. You can retrieve the JSON response by using the -JSON parameter.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER URI
URI of the Unity ressource (ex: /api/types/lun/instances)
.PARAMETER JSON
Output in the JSON Format
.EXAMPLE
Get-UnityItem -URI '/api/types/pool/instances'
Retrieve information about pools. Return a powershell object
.EXAMPLE
Get-UnityItem -URI '/api/types/pool/instances' -JSON
Retrieves information about pools. Return data in the JSON format
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,HelpMessage = 'EMC Unity Session')]
[String]$URI,
[Parameter(Mandatory = $false,HelpMessage = 'Output in the JSON Format')]
[Switch]$JSON
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing arrays
$ResultCollection = @()
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
#Building the URI
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URI: $URL"
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'GET'
#Formating the result. Converting it from JSON to a Powershell object
If ($JSON) {
$results = $request.content
} else {
$results = $request.content | ConvertFrom-Json
}
Write-Output $results
} else {
Write-Host "You are no longer connected to EMC Unity array: $($Sess.Server)"
}
}
}
Process {}
End {}
}
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityPool.ps1
|
Set-UnityPool.ps1
|
Function Set-UnityPool {
<#
.SYNOPSIS
Modifies storage pool parameters.
.DESCRIPTION
Modifies storage pool parameters.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.PARAMETER ID
ID of the pool or Pool Object.
.PARAMETER NewName
New name of the pool.
.PARAMETER Description
Description of the pool.
.PARAMETER AddVirtualDisk
Virtual Disks only with associated parameters to add to the pool. See examples for details.
.PARAMETER AddraidGroup
Parameters to add RAID groups to the pool (disk group, number of disks, RAID level, stripe length). See examples for details.
.PARAMETER isFASTCacheEnabled
Specify whether to enable FAST Cache on the storage pool.
.PARAMETER isFASTVpScheduleEnabled
Specify whether to enable scheduled data relocations for the pool.
.PARAMETER alertThreshold
For thin provisioning, specify the threshold, as a percentage, when the system will alert on the amount of subscription space used.
.PARAMETER isHarvestEnabled
Indicate whether the system should check the pool full high water mark for autodelete.
.PARAMETER poolSpaceHarvestHighThreshold
Specify the pool full high watermark for the storage pool.
.PARAMETER poolSpaceHarvestLowThreshold
Specify the pool full low watermark for the storage pool.
.PARAMETER isSnapHarvestEnabled
Indicate whether the system should check the snapshot space used high water mark for auto-delete.
.PARAMETER snapSpaceHarvestHighThreshold
Specify the snapshot space used high watermark to trigger auto-delete on the storage pool.
.PARAMETER snapSpaceHarvestLowThreshold
Specify the snapshot space used low watermark to trigger auto-delete on the storage pool.
.EXAMPLE
Set-UnityPool -ID 'pool_10' -Description 'Modified description'
Change the description of the pool with ID 'pool_10'
.EXAMPLE
Set-UnityPool -ID 'pool_10' -AddVirtualDisk @{'id'='vdisk_1';'tier'='Performance'}
Add a virtual disk 'vdisk_1' to the pool with ID 'pool_10'
.EXAMPLE
Set-UnityPool -ID 'pool_10' -AddraidGroup @{"id"='dg_8';"numDisks"= 8; 'raidType'='RAID6'; 'stripeWidth'='8'}
Add a raid group 'dg_8' to the pool with ID 'pool_10'
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High',DefaultParameterSetName="RaidGroup")]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#UnityPool
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Pool ID or Pool Object')]
[String[]]$ID,
[Parameter(Mandatory = $false,HelpMessage = 'New Name of the Pool')]
[String]$NewName,
[Parameter(Mandatory = $false,HelpMessage = 'Pool Description')]
[String]$Description,
[Parameter(Mandatory = $false,ParameterSetName="VirtualDisk",HelpMessage = 'Parameters to add virtual disks to the pools')]
[array]$AddVirtualDisk,
[Parameter(Mandatory = $false,ParameterSetName="RaidGroup",HelpMessage = 'Parameters to add RAID groups to the pool (disk group, number of disks, RAID level, stripe length)')]
[array]$AddraidGroup,
[Parameter(Mandatory = $false,HelpMessage = 'Threshold at which the system will generate alerts about the free space in the pool')]
[Int]$alertThreshold,
[Parameter(Mandatory = $false,HelpMessage = 'Pool used space high threshold at which the system will automatically starts to delete snapshots in the pool, specified as a percentage with .01% granularity')]
[Long]$poolSpaceHarvestHighThreshold,
[Parameter(Mandatory = $false,HelpMessage = 'Pool used space low threshold under which the system will automatically stop deletion of snapshots in the pool, specified as a percentage with .01% granularity')]
[Long]$poolSpaceHarvestLowThreshold,
[Parameter(Mandatory = $false,HelpMessage = 'Snapshot used space high threshold at which the system automatically starts to delete snapshots in the pool, specified as a percentage with .01% granularity.')]
[Long]$snapSpaceHarvestHighThreshold,
[Parameter(Mandatory = $false,HelpMessage = 'Snapshot used space low threshold below which the system will stop automatically deleting snapshots in the pool, specified as a percentage with .01% granularity.')]
[Long]$snapSpaceHarvestLowThreshold,
[Parameter(Mandatory = $false,HelpMessage = 'Is Harvest Enabled ?')]
[Bool]$isHarvestEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Is Snapshot Harvest Enabled')]
[Bool]$isSnapHarvestEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Is FAST Cache Enabled ?')]
[Bool]$isFASTCacheEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Is FAST Vp Schedule Enabled ? ')]
[Bool]$isFASTVpScheduleEnabled
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/pool/<id>/action/modify'
$Type = 'Pool'
$TypeName = 'UnityPool'
$StatusCode = 204
$tier = @{
"Extreme_Performance" = "10"
"Performance" = "20"
"Capacity" = "30"
}
$Raid =@{
"None" = "0"
"RAID5" = "1"
"RAID0" = "2"
"RAID1" = "3"
"RAID3" = "4"
"RAID10" = "7"
"RAID6" = "10"
"Mixed" = "12"
"Automatic" = "48879"
}
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityPool -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityPool -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
# Name parameter
If ($NewName) {
$body["name"] = "$($NewName)"
}
# Description parameter
If ($Description) {
$body["description"] = "$($Description)"
}
If ($AddVirtualDisk) {
# addPoolUnitParameters parameter
$body["addPoolUnitParameters"] = @()
Foreach ($vdisk in $AddVirtualDisk) {
$addPoolUnitParameters = @{}
$addPoolUnitParameters["poolUnit"] = @{}
$poolUnit = @{}
$poolUnit["id"] = "$($vdisk['id'])"
$tierType = "$($tier["$($vdisk['tier'])"])"
$addPoolUnitParameters["poolUnit"] = $poolUnit
$addPoolUnitParameters["tierType"] = $tierType
$body["addPoolUnitParameters"] += $addPoolUnitParameters
}
}
If ($AddraidGroup) {
# addRaidGroupParameters parameter
$body["addRaidGroupParameters"] = @()
Foreach ($rg in $AddraidGroup) {
$addRaidGroupParameters = @{}
$addRaidGroupParameters["dskGroup"] = @{}
$diskGroup = @{}
$diskGroup["id"] = "$($rg['id'])"
$addRaidGroupParameters["dskGroup"] = $diskGroup
$addRaidGroupParameters["numDisks"] = "$($rg['numDisks'])"
$addRaidGroupParameters["raidType"] = "$($raid["$($rg['raidType'])"])"
$addRaidGroupParameters["stripeWidth"] = "$($rg['stripeWidth'])"
$body["addRaidGroupParameters"] += $addRaidGroupParameters
}
}
If ($alertThreshold) {
$body["alertThreshold"] = "$($alertThreshold)"
}
If ($poolSpaceHarvestHighThreshold) {
$body["poolSpaceHarvestHighThreshold"] = "$($poolSpaceHarvestHighThreshold)"
}
If ($poolSpaceHarvestLowThreshold) {
$body["poolSpaceHarvestLowThreshold"] = "$($poolSpaceHarvestLowThreshold)"
}
If ($snapSpaceHarvestHighThreshold) {
$body["snapSpaceHarvestHighThreshold"] = "$($snapSpaceHarvestHighThreshold)"
}
If ($snapSpaceHarvestLowThreshold) {
$body["snapSpaceHarvestLowThreshold"] = "$($snapSpaceHarvestLowThreshold)"
}
If ($PSBoundParameters.ContainsKey('isHarvestEnabled')) {
$body["isHarvestEnabled"] = $isHarvestEnabled
}
If ($PSBoundParameters.ContainsKey('isSnapHarvestEnabled')) {
$body["isSnapHarvestEnabled"] = $isSnapHarvestEnabled
}
If ($PSBoundParameters.ContainsKey('isFASTCacheEnabled')) {
$body["isFASTCacheEnabled"] = $isFASTCacheEnabled
}
If ($PSBoundParameters.ContainsKey('isFASTVpScheduleEnabled')) {
$body["isFASTVpScheduleEnabled"] = $isFASTVpScheduleEnabled
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityPool -Session $Sess -id $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnitySnapSchedule.ps1
|
Set-UnitySnapSchedule.ps1
|
Function Set-UnitySnapSchedule {
<#
.SYNOPSIS
Modifies snapshot schedule parameters.
.DESCRIPTION
Modifies snapshot schedule parameters. You can add or delete rules. Rules can be added one at a time.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.PARAMETER ID
ID of the snapshot Schedule or snapshot Schedule Object.
.PARAMETER addRules
Rules to add to the snapshot schedule.
.PARAMETER removeRuleIds
ID of the rules to remove from the snapshot schedule.
.PARAMETER type
Type of snapshot schedule rule. Values are:
- N_HOURS_AT_MM: Snap every <interval> hours, at <minutes> past the hour. Supported parameters: interval (required), minutes (optional, default 0).
- DAY_AT_HHMM: Specify a list of <hour[,...]> to snap one or more times each day at <minutes> past the hour. Supported parameters: hours (at least one required), minutes (optional).
- N_DAYS_AT_HHMM: Snap every <interval> days at the time <hours>:<minutes>. Supported Parameters: interval (required), hours (optional, exactly one), minutes (optional).
- SELDAYS_AT_HHMM: Snap on the selected <daysOfWeek>, at the time <hours>:<minutes>. Supported parameters: daysOfWeek (at least one required), hours (optional, default 0), minutes (optional, default 0).
- NTH_DAYOFMONTH_AT_HHMM: Snap on the selected <daysOfMonth>, at the time <hours>:<minutes>. Supported parameters: daysOfMonth (at least one required), hours (optional, default 0), minutes (optional, default 0).
.PARAMETER minute
Minute frequency for the snapshot schedule rule.
.PARAMETER hours
Hourly frequency for the snapshot schedule rule.
.PARAMETER daysOfWeek
Days of the week for which the snapshot schedule rule applies.
.PARAMETER daysOfMonth
Days of the month for which the snapshot schedule rule applies.
.PARAMETER interval
Number of days or hours between snaps, depending on the rule type.
.PARAMETER isAutoDelete
Indicates whether the system can automatically delete the snapshot based on pool automatic-deletion thresholds. Values are:
- $True: System can delete the snapshot based on pool automatic-deletion thresholds.
- $False: System cannot delete the snapshot based on pool automatic-deletion thresholds.
.PARAMETER retentionTime
(Applies when the value of the isAutoDelete attribute is false.) Period of time in seconds for which to keep the snapshot.
.PARAMETER accessType
For a file system or VMware NFS datastore snapshot schedule, indicates whether the snapshot created by the schedule has checkpoint or protocol type access
.EXAMPLE
Set-UnitySnapSchedule -ID 'snapSch_6' -addRules -Type N_HOURS_AT_MM -Interval 12 -Minutes 30
Add rule to snapshot schedule with ID 'snapSch_6'. Snap every 12 hours, at 30 minutes past the hour.
.EXAMPLE
Set-UnitySnapSchedule -ID 'snapSch_6' -removeRuleIds 'SchedRule_11'
Remove rule ID 'SchedRule_11' to snapshot schedule with ID 'snapSch_6'.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High',DefaultParameterSetName="addRules")]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,ParameterSetName="addRules",Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'ID of the snapshot Schedule or snapshot Schedule Object.')]
[Parameter(Mandatory = $true,ParameterSetName="removeRuleIds",Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'ID of the snapshot Schedule or snapshot Schedule Object.')]
[String[]]$ID,
# Add rules
[Parameter(Mandatory = $true,ParameterSetName="addRules",HelpMessage = 'Unique identifiers of the rules to remove from the snapshot schedule.')]
[switch]$addRules,
[Parameter(Mandatory = $true,ParameterSetName="addRules",HelpMessage = 'Type of snapshot schedule rule.')]
[ScheduleTypeEnum]$type,
[Parameter(Mandatory = $false,ParameterSetName="addRules",HelpMessage = 'Minute frequency for the snapshot schedule rule.')]
[UInt32]$minute,
[Parameter(Mandatory = $false,ParameterSetName="addRules",HelpMessage = 'Hourly frequency for the snapshot schedule rule.')]
[UInt32[]]$hours,
[Parameter(Mandatory = $false,ParameterSetName="addRules",HelpMessage = 'Days of the week for which the snapshot schedule rule applies.')]
[DayOfWeekEnum[]]$daysOfWeek,
[Parameter(Mandatory = $false,ParameterSetName="addRules",HelpMessage = 'Days of the month for which the snapshot schedule rule applies.')]
[UInt32]$daysOfMonth,
[Parameter(Mandatory = $false,ParameterSetName="addRules",HelpMessage = 'Number of days or hours between snaps, depending on the rule type.')]
[UInt32]$interval,
[Parameter(Mandatory = $false,ParameterSetName="addRules",HelpMessage = 'Indicates whether the system can automatically delete the snapshot based on pool automatic-deletion thresholds.')]
[bool]$isAutoDelete,
[Parameter(Mandatory = $false,ParameterSetName="addRules",HelpMessage = '(Applies when the value of the isAutoDelete attribute is false.) Period of time in seconds for which to keep the snapshot.')]
[UInt64]$retentionTime,
[Parameter(Mandatory = $false,ParameterSetName="addRules",HelpMessage = 'For a file system or VMware NFS datastore snapshot schedule, indicates whether the snapshot created by the schedule has checkpoint or protocol type access.')]
[FilesystemSnapAccessTypeEnum]$accessType,
# Remove rules ID
[Parameter(Mandatory = $true,ParameterSetName="removeRuleIds",HelpMessage = 'Unique identifiers of the rules to remove from the snapshot schedule.')]
[string[]]$removeRuleIds
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/snapSchedule/<id>/action/modify'
$ObjectType = 'Snapshot Schedule'
$TypeName = 'UnitySnapSchedule'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnitySnapSchedule -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnitySnapSchedule -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
Switch ($PsCmdlet.ParameterSetName) {
'addRules' {
$body["addRules"] = @()
$snapScheduleRule = @{}
$snapScheduleRule["type"] = $type
If ($PSBoundParameters.ContainsKey('minute')) {
$snapScheduleRule["minute"] = $minute
}
If ($PSBoundParameters.ContainsKey('hours')) {
$snapScheduleRule["hours"] = @()
$hoursParameters += $hours
$snapScheduleRule["hours"] = $hoursParameters
}
If ($PSBoundParameters.ContainsKey('daysOfWeek')) {
$snapScheduleRule["daysOfWeek"] = $daysOfWeek
}
If ($PSBoundParameters.ContainsKey('daysOfMonth')) {
$snapScheduleRule["daysOfMonth"] = $daysOfMonth
}
If ($PSBoundParameters.ContainsKey('interval')) {
$snapScheduleRule["interval"] = $interval
}
If ($PSBoundParameters.ContainsKey('isAutoDelete')) {
$snapScheduleRule["isAutoDelete"] = $isAutoDelete
}
If ($PSBoundParameters.ContainsKey('retentionTime')) {
$snapScheduleRule["retentionTime"] = $retentionTime
}
If ($PSBoundParameters.ContainsKey('accessType')) {
$snapScheduleRule["accessType"] = $accessType
}
$body["addRules"] += $snapScheduleRule
}
'removeRuleIds' {
If ($PSBoundParameters.ContainsKey('removeRuleIds')) {
$body["removeRuleIds"] = @()
$body["removeRuleIds"] += $removeRuleIds
}
}
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $ObjectType $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$ObjectType with ID $ObjectID has been modified"
Get-UnitySnapSchedule -Session $Sess -id $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/New-UnityHost.ps1
|
New-UnityHost.ps1
|
Function New-UnityHost {
<#
.SYNOPSIS
Create a host configuration.
.DESCRIPTION
Create a host configuration.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
New-UnityHost -Name 'Host01'
Create Host named 'Host01'.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#Host Name
[Parameter(Mandatory = $true,Position = 1,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Host Name')]
[String[]]$Name,
#Type of host configuration.
[Parameter(Mandatory = $false,HelpMessage = 'Type of host configuration.')]
[HostTypeEnum]$type='HostManual',
#Host Description
[Parameter(Mandatory = $false,HelpMessage = 'Host Description')]
[String]$Description,
#Operating system running on the host.
[Parameter(Mandatory = $false,HelpMessage = 'Operating system running on the host.')]
[string]$osType
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
## Variables
$URI = '/api/types/host/instances'
$TypeName = 'Host'
$StatusCode = 201
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
Foreach ($n in $Name) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
# Name parameter
$body["name"] = $n
# type parameter
$body["type"] = $type
If ($PSBoundParameters.ContainsKey('description')) {
$body["description"] = $description
}
If ($PSBoundParameters.ContainsKey('osType')) {
$body["osType"] = $osType
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
##Building the URL
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Create $TypeName $n")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
Write-Verbose "Request status code: $($request.StatusCode)"
If ($request.StatusCode -eq $StatusCode) {
#Formating the result. Converting it from JSON to a Powershell object
$results = ($request.content | ConvertFrom-Json).content
Write-Verbose "$TypeName with the ID $($results.id) has been created"
Get-UnityHost -Session $Sess -ID $results.id
} # End If ($request.StatusCode -eq $StatusCode)
} # End If ($Sess.TestConnection())
} # End Foreach
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/New-UnityVMwareNFS.ps1
|
New-UnityVMwareNFS.ps1
|
Function New-UnityVMwareNFS {
<#
.SYNOPSIS
Creates a Unity VMware NFS LUN.
.DESCRIPTION
Creates a Unity VMware NFS LUN.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Name
VMware NFS LUN Name
.PARAMETER Description
VMware NFS LUN Description
.PARAMETER snapSchedule
ID of a protection schedule to apply to the VMware NFS LUN
.PARAMETER isSnapSchedulePaused
Is assigned snapshot schedule is paused ? (Default is false)
.PARAMETER Pool
VMware NFS LUN Pool ID
.PARAMETER nasServer
VMware NFS LUN nasServer ID
.PARAMETER isThinEnabled
Indicates whether to enable thin provisioning for VMware NFS LUN. Default is $True
.PARAMETER Size
VMware NFS LUN Size
.PARAMETER hostIOSize
Typical write I/O size from the host to the VMware NFS LUN
.PARAMETER tieringPolicy
VMware NFS LUN tiering policy
.PARAMETER defaultAccess
Default access level for all hosts accessing the VMware NFS LUN.
.PARAMETER minSecurity
Minimal security level that must be provided by a client to mount the VMware NFS LUN.
.PARAMETER noAccessHosts
Hosts with no access to the VMware NFS LUN or its snapshots, as defined by the host resource type.
.PARAMETER readOnlyHosts
Hosts with read-only access to the VMware NFS LUN and its snapshots, as defined by the host resource type.
.PARAMETER readWriteHosts
Hosts with read-write access to the VMware NFS LUN and its snapshots, as defined by the host resource type.
.PARAMETER rootAccessHosts
Hosts with root access to the VMware NFS LUN and its snapshots, as defined by the host resource type.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
New-UnityVMwareNFS -Name DATASTORE-NFS-01 -Pool pool_1 -nasServer nas_1 -Size 10GB
Create a VMware NFS LUN named 'DATASTORE-NFS-01' on pool 'pool_1' and NAS server 'nas_1' and with a size of '10GB' bytes
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#Create VMware NFS LUN
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'VMware NFS LUN Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,HelpMessage = 'VMware NFS LUN Description')]
[String]$Description,
#snapScheduleParameters
[Parameter(Mandatory = $false,HelpMessage = 'ID of a protection schedule to apply to the VMware NFS LUN')]
[String]$snapSchedule,
[Parameter(Mandatory = $false,HelpMessage = 'Is assigned snapshot schedule is paused ? (Default is false)')]
[bool]$isSnapSchedulePaused = $false,
#fsParameters
[Parameter(Mandatory = $true,HelpMessage = 'VMware NFS LUN Pool ID')]
[String]$Pool,
[Parameter(Mandatory = $true,HelpMessage = 'VMware NFS LUN nasServer ID')]
[String]$nasServer,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether to enable thin provisioning for VMware NFS LUN')]
[String]$isThinEnabled = $true,
[Parameter(Mandatory = $true,HelpMessage = 'VMware NFS LUN Size')]
[uint64]$Size,
[Parameter(Mandatory = $false,HelpMessage = 'Typical write I/O size from the host to the VMware NFS LUN')]
[HostIOSizeEnum]$hostIOSize,
#$nfsShareParameters
[Parameter(Mandatory = $false,HelpMessage = 'Default access level for all hosts accessing the NFS share.')]
[NFSShareDefaultAccessEnum]$defaultAccess = 'NoAccess',
[Parameter(Mandatory = $false,HelpMessage = 'Minimal security level that must be provided by a client to mount the NFS share.')]
[NFSShareSecurityEnum]$minSecurity,
[Parameter(Mandatory = $false,HelpMessage = 'Hosts with no access to the NFS share or its snapshots.')]
[string[]]$noAccessHosts,
[Parameter(Mandatory = $false,HelpMessage = 'Hosts with read-only access to the NFS share and its snapshots.')]
[string[]]$readOnlyHosts,
[Parameter(Mandatory = $false,HelpMessage = 'Hosts with read-write access to the NFS share and its snapshots.')]
[string[]]$readWriteHosts,
[Parameter(Mandatory = $false,HelpMessage = 'Hosts with root access to the NFS share and its snapshots.')]
[string[]]$rootAccessHosts,
##fastVPParameterseters
[Parameter(Mandatory = $false,HelpMessage = 'VMware NFS LUN tiering policy')]
[TieringPolicyEnum]$tieringPolicy
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
## Variables
$URI = '/api/types/storageResource/action/createVmwareNfs'
$Type = 'VMware NFS LUN'
$StatusCode = 200
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
Foreach ($n in $Name) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
# Name parameter
$body["name"] = "$($n)"
# Description parameter
If ($Description) {
$body["description"] = "$($Description)"
}
# fsParameters parameter
$body["fsParameters"] = @{}
$fsParameters = @{}
$poolParameters = @{}
$poolParameters["id"] = "$($Pool)"
$fsParameters["pool"] = $poolParameters
$nasServerParameters = @{}
$nasServerParameters["id"] = "$($nasServer)"
$fsParameters["nasServer"] = $nasServerParameters
$fsParameters["size"] = $($Size)
# isThinEnabled
If ($PSBoundParameters.ContainsKey('isThinEnabled')) {
$fsParameters["isThinEnabled"] = $isThinEnabled
}
# hostIOSize
If ($PSBoundParameters.ContainsKey('hostIOSize')) {
$fsParameters["hostIOSize"] = $hostIOSize
}
# fastVPParameters
If ($PSBoundParameters.ContainsKey('tieringPolicy')) {
$fastVPParameters = @{}
$fastVPParameters['tieringPolicy'] = $tieringPolicy
$fsParameters["fastVPParameters"] = $fastVPParameters
}
$body["fsParameters"] = $fsParameters
#nfsShareParameters
$body["nfsShareParameters"] = @{}
$nfsShareParameters = @{}
$nfsShareParameters["defaultAccess"] = $defaultAccess
If ($PSBoundParameters.ContainsKey('minSecurity')) {
$nfsShareParameters["minSecurity"] = $minSecurity
}
If ($PSBoundParameters.ContainsKey('noAccessHosts')) {
$nfsShareParameters["noAccessHosts"] = @()
foreach ($h in $noAccessHosts) {
$HostParam = @{}
$HostParam['id'] = $h
$nfsShareParameters["noAccessHosts"] += $HostParam
}
}
If ($PSBoundParameters.ContainsKey('readOnlyHosts')) {
$nfsShareParameters["readOnlyHosts"] = @()
foreach ($h in $readOnlyHosts) {
$HostParam = @{}
$HostParam['id'] = $h
$nfsShareParameters["readOnlyHosts"] += $HostParam
}
}
If ($PSBoundParameters.ContainsKey('readWriteHosts')) {
$nfsShareParameters["readWriteHosts"] = @()
foreach ($h in $readWriteHosts) {
$HostParam = @{}
$HostParam['id'] = $h
$nfsShareParameters["readWriteHosts"] += $HostParam
}
}
If ($PSBoundParameters.ContainsKey('rootAccessHosts')) {
$nfsShareParameters["rootAccessHosts"] = @()
foreach ($h in $rootAccessHosts) {
$HostParam = @{}
$HostParam['id'] = $h
$nfsShareParameters["rootAccessHosts"] += $HostParam
}
}
$body["nfsShareParameters"] = $nfsShareParameters
#snapScheduleParameters
If ($snapSchedule) {
$body["snapScheduleParameters"] = @{}
$snapScheduleParameters = @{}
$snapScheduleParam = @{}
$snapScheduleParam["id"] ="$($snapSchedule)"
$snapScheduleParameters["snapSchedule"] = $snapScheduleParam
$snapScheduleParameters["isSnapSchedulePaused"]= "$($isSnapSchedulePaused)"
$body["snapScheduleParameters"] = $snapScheduleParameters
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
##Building the URL
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Create $Type $n")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
Write-Verbose "Request status code: $($request.StatusCode)"
If ($request.StatusCode -eq $StatusCode) {
#Formating the result. Converting it from JSON to a Powershell object
$results = ($request.content | ConvertFrom-Json).content
$Storageresource = Get-UnitystorageResource -session $Sess -ID $results.storageResource.id
Write-Verbose "$Type with the ID $($Storageresource.filesystem.id) has been created"
Get-UnityVMwareNFS -Session $Sess -ID $Storageresource.filesystem.id
} # End If ($request.StatusCode -eq $StatusCode)
} # End If ($Sess.TestConnection())
} # End Foreach
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnityNFSServer.ps1
|
Set-UnityNFSServer.ps1
|
Function Set-UnityNFSServer {
<#
.SYNOPSIS
Modifies NFS Server.
.DESCRIPTION
Modifies NFS Server.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Set-UnityNFSServer -ID 'default' -Address smtp.example.com
Modifies the default NFS Server
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#NFS Server ID or Object.
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'NFS Server ID or Object.')]
[String[]]$ID,
#Host name of the NFS server. If host name is not specified then SMB server name or NAS server name will be used to auto generate the host name.
[Parameter(Mandatory = $false,HelpMessage = 'Host name of the NFS server. If host name is not specified then SMB server name or NAS server name will be used to auto generate the host name.')]
[string]$hostName,
#Indicates whether the NFSv4 is enabled on the NAS server specified in the nasServer attribute.
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether the NFSv4 is enabled on the NAS server specified in the nasServer attribute.')]
[bool]$nfsv4Enabled,
#Indicates whether the secure NFS is enabled.
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether the secure NFS is enabled.')]
[bool]$isSecureEnabled,
#Type of Kerberos Domain Controller used for secure NFS service.
[Parameter(Mandatory = $false,HelpMessage = 'Type of Kerberos Domain Controller used for secure NFS service.')]
[KdcTypeEnum]$kdcType,
#Keep Service Principal Name (SPN) in Kerberos Domain Controller.
[Parameter(Mandatory = $true,HelpMessage = 'Keep Service Principal Name (SPN) in Kerberos Domain Controller.')]
[switch]$skipUnjoin,
#Kerberos Domain Controller administrator's name.
[Parameter(Mandatory = $false,HelpMessage = 'Kerberos Domain Controller administrator s name.')]
[string]$kdcUsername,
#Kerberos Domain Controller administrator's password.
[Parameter(Mandatory = $false,HelpMessage = 'Kerberos Domain Controller administrator s password.')]
[string]$kdcPassword,
#Support for more than 16 Unix groups.
[Parameter(Mandatory = $false,HelpMessage = 'Support for more than 16 Unix groups.')]
[bool]$isExtendedCredentialsEnabled,
#Credential cache refresh timeout. Resolution is in minutes.
#Default value is 15 minutes.
[Parameter(Mandatory = $false,HelpMessage = 'Credential cache refresh timeout. Resolution is in minutes.')]
[DateTime]$credentialsCacheTTL
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/nfsServer/<id>/action/modify'
$Type = 'NFS Server'
$TypeName = 'UnityNfsServer'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityNFSServer -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityNFSServer -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
If ($PSBoundParameters.ContainsKey('hostName')) {
$body["hostName"] = $hostName
}
If ($PSBoundParameters.ContainsKey('nfsv4Enabled')) {
$body["nfsv4Enabled"] = $nfsv4Enabled
}
If ($PSBoundParameters.ContainsKey('isSecureEnabled')) {
$body["isSecureEnabled"] = $isSecureEnabled
}
If ($PSBoundParameters.ContainsKey('kdcType')) {
$body["kdcType"] = $kdcType
}
If ($PSBoundParameters.ContainsKey('skipUnjoin')) {
$body["skipUnjoin"] = $skipUnjoin
}
If ($PSBoundParameters.ContainsKey('kdcUsername')) {
$body["kdcUsername"] = $kdcUsername
}
If ($PSBoundParameters.ContainsKey('kdcPassword')) {
$body["kdcPassword"] = $kdcPassword
}
If ($PSBoundParameters.ContainsKey('isExtendedCredentialsEnabled')) {
$body["isExtendedCredentialsEnabled"] = $isExtendedCredentialsEnabled
}
If ($PSBoundParameters.ContainsKey('credentialsCacheTTL')) {
$body["credentialsCacheTTL"] = $credentialsCacheTTL
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnityNFSServer -Session $Sess -id $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityNFSShare.ps1
|
Get-UnityNFSShare.ps1
|
Function Get-UnityNFSShare {
<#
.SYNOPSIS
Queries the EMC Unity array to retrieve informations about NFS Share.
.DESCRIPTION
Queries the EMC Unity array to retrieve informations about NFS Share.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER Name
Specifies the object name.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityNFSShare
Retrieve information about NFS Share
.EXAMPLE
Get-UnityNFSShare -Name 'SHARE01'
Retrieves information about NFS Share named SHARE01
#>
[CmdletBinding(DefaultParameterSetName="Name")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="Name",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'NFS Share Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'NFS Share ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/nfsShare/instances' #URI
$TypeName = 'UnityNFSShare'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityHostInitiator.ps1
|
Get-UnityHostInitiator.ps1
|
Function Get-UnityHostInitiator {
<#
.SYNOPSIS
View details about host initiators.
.DESCRIPTION
View details about host initiators on the system.
You need to have an active session with the array.
.NOTES
Written by Erwan Quélin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER ID
Specifies the object ID.
.PARAMETER PortWWN
Specifies the port WWN.
.EXAMPLE
Get-UnityHostInitiator
Retrieve information about all hosts
.EXAMPLE
Get-UnityHostInitiator -ID 'Host_67'
Retrieves information about host initiator named 'Host_67'
#>
[CmdletBinding(DefaultParameterSetName="ID")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Host Initiator ID')]
[String[]]$ID,
[Parameter(Mandatory = $false,ParameterSetName="PortWwn",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Initiator Port WWN')]
[String[]]$PortWWN
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/hostInitiator/instances' #URI
$TypeName = 'UnityHostInitiator'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Get-UnityDnsServer.ps1
|
Get-UnityDnsServer.ps1
|
Function Get-UnityDNSServer {
<#
.SYNOPSIS
Information about DNS Servers.
.DESCRIPTION
Information about DNS Servers.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specifies an UnitySession Object.
.PARAMETER ID
Specifies the object ID.
.EXAMPLE
Get-UnityDNSServer
Retrieve informations about the DNS server.
#>
[CmdletBinding(DefaultParameterSetName="ID")]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'DNS ID')]
[String[]]$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
#Initialazing variables
$URI = '/api/types/dnsServer/instances' #URI for the ressource (example: /api/types/lun/instances)
$TypeName = 'UnityDnsServer'
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key $PsCmdlet.ParameterSetName -Value $PSBoundParameters[$PsCmdlet.ParameterSetName]
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Set-UnitySMTPServer.ps1
|
Set-UnitySMTPServer.ps1
|
Function Set-UnitySMTPServer {
<#
.SYNOPSIS
Modifies SMTP Server.
.DESCRIPTION
Modifies SMTP Server.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
SMTP Server ID or Object.
.PARAMETER address
IP address of the SMTP server.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Set-UnitySMTPServer -ID 'default' -Address smtp.example.com
Modifies the default SMTP Server
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'ID of the SMTP Server')]
[String[]]$ID,
[Parameter(Mandatory = $true,HelpMessage = 'IP address of the SMTP server.')]
[String]$address
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/smtpServer/<id>/action/modify'
$Type = 'SMTP Server'
$TypeName = 'UnitySMTPServer'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnitySMTPServer -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnitySMTPServer -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
}
If ($ObjectID) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
$body["address"] = $address
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Modify $Type $ObjectName")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been modified"
Get-UnitySMTPServer -Session $Sess -id $ObjectID
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/New-UnityIscsiPortal.ps1
|
New-UnityIscsiPortal.ps1
|
Function New-UnityiSCSIPortal {
<#
.SYNOPSIS
Create a new iSCSI portal.
.DESCRIPTION
Create a new iSCSI portal.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ethernetPort
Ethernet port used by the iSCSI portal.
.PARAMETER ipAddress
IPv4 or IPv6 address for the iSCSI Network Portal.
.PARAMETER netmask
IPv4 netmask for the iSCSI Network Portal, if the iSCSI Network Portal uses an IPv4 address.
.PARAMETER v6PrefixLength
Prefix length in bits for IPv6 address.
.PARAMETER gateway
IPv4 or IPv6 gateway address for the iSCSI Network Portal.
.PARAMETER vlanId
Ethernet virtual LAN identifier used for tagging iSCSI portal outgoing packets and for filtering iSCSI portal incoming packets.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
New-UnityiSCSIPortal -ethernetPort 'spa_eth0' -ipAddress '192.168.0.1' -netmask '255.255.255.0' -gateway '192.168.0.254'
Create a new iSCSI portal.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,HelpMessage = 'Ethernet port ID.')]
[string]$ethernetPort,
[Parameter(Mandatory = $true,HelpMessage = 'IPv4 or IPv6 address for the interface.')]
[string]$ipAddress,
[Parameter(Mandatory = $false,HelpMessage = 'IPv4 netmask for the interface, if the interface uses an IPv4 address.')]
[string]$netmask,
[Parameter(Mandatory = $false,HelpMessage = 'Prefix length in bits for IPv6 address.')]
[String[]]$v6PrefixLength,
[Parameter(Mandatory = $false,HelpMessage = 'Ethernet virtual LAN identifier used for tagging iSCSI portal outgoing packets and for filtering iSCSI portal incoming packets.')]
[String[]]$vlanId,
[Parameter(Mandatory = $false,HelpMessage = 'IPv4 or IPv6 gateway address for the interface.')]
[string]$gateway
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
## Variables
$URI = '/api/types/iscsiPortal/instances'
$Type = 'iSCSI Portal'
$StatusCode = 201
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
#### REQUEST BODY
#Creation of the body hash
$body = @{}
#Body arguments
#ethernetPort parameter
$body["ethernetPort"] = @{}
$ethernetPortParameters = @{}
$ethernetPortParameters["id"] = "$($ethernetPort)"
$body["ethernetPort"] = $ethernetPortParameters
$body["ipAddress"] = $ipAddress
If ($PSBoundParameters.ContainsKey('netmask')) {
$body["netmask"] = "$($netmask)"
}
If ($PSBoundParameters.ContainsKey('v6PrefixLength')) {
$body["v6PrefixLength"] = "$($v6PrefixLength)"
}
If ($PSBoundParameters.ContainsKey('vlanId')) {
$body["vlanId"] = "$($vlanId)"
}
If ($PSBoundParameters.ContainsKey('gateway')) {
$body["gateway"] = "$($gateway)"
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
##Building the URL
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Create $Type $n")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
Write-Verbose "Request status code: $($request.StatusCode)"
If ($request.StatusCode -eq $StatusCode) {
#Formating the result. Converting it from JSON to a Powershell object
$results = ($request.content | ConvertFrom-Json).content
Write-Verbose "$Type with the ID $($results.id) has been created"
Get-UnityiSCSIPortal -Session $Sess -Id $results.id
} # End If ($request.StatusCode -eq $StatusCode)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/Remove-UnityvCenter.ps1
|
Remove-UnityvCenter.ps1
|
Function Remove-UnityvCenter {
<#
.SYNOPSIS
Delete vCenter Server.
.DESCRIPTION
Delete vCenter Server.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER ID
vCenter ID or Object.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running.
If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
Remove-UnityvCenter -ID 'default'
Delete the vCenter server with ID 'default'
.EXAMPLE
Get-UnityvCenter -Name 'default' | Remove-UnityvCenter
Delete the vCenter server with ID 'default'. vCenter server informations are provided by the Get-UnityvCenter through the pipeline.
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'vCenter Server ID or Object')]
$ID
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
# Variables
$URI = '/api/instances/hostContainer/<id>'
$Type = 'vCenter'
$TypeName = 'UnityHostContainer'
$StatusCode = 204
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
If ($Sess.TestConnection()) {
Foreach ($i in $ID) {
# Determine input and convert to object if necessary
Switch ($i.GetType().Name)
{
"String" {
$Object = get-UnityvCenter -Session $Sess -ID $i
$ObjectID = $Object.id
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
"$TypeName" {
Write-Verbose "Input object type is $($i.GetType().Name)"
$ObjectID = $i.id
If ($Object = Get-UnityvCenter -Session $Sess -ID $ObjectID) {
If ($Object.Name) {
$ObjectName = $Object.Name
} else {
$ObjectName = $ObjectID
}
}
}
} # End Switch
If ($ObjectID) {
#Building the URL
$FinalURI = $URI -replace '<id>',$ObjectID
$URL = 'https://'+$sess.Server+$FinalURI
Write-Verbose "URL: $URL"
if ($pscmdlet.ShouldProcess($Sess.Name,"Delete $Type $ObjectName")) {
#Sending the request
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'DELETE'
}
If ($request.StatusCode -eq $StatusCode) {
Write-Verbose "$Type with ID $ObjectID has been deleted"
} # End If ($request.StatusCode -eq $StatusCode)
} else {
Write-Warning -Message "$Type with ID $i does not exist on the array $($sess.Name)"
} # End If ($ObjectID)
} # End Foreach ($i in $ID)
} # End If ($Sess.TestConnection())
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/New-UnityFilesystem.ps1
|
New-UnityFilesystem.ps1
|
Function New-UnityFilesystem {
<#
.SYNOPSIS
Creates a Unity Filesystem.
.DESCRIPTION
Creates a Unity Filesystem.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Name
Filesystem Name
.PARAMETER Description
Filesystem Description
.PARAMETER snapSchedule
ID of a protection schedule to apply to the filesystem
.PARAMETER isSnapSchedulePaused
Is assigned snapshot schedule is paused ? (Default is false)
.PARAMETER Pool
Filesystem Pool ID
.PARAMETER nasServer
Filesystem nasServer ID
.PARAMETER supportedProtocols
Filesystem supported protocols
.PARAMETER isFLREnabled
Indicates whether File Level Retention (FLR) is enabled for the file system
.PARAMETER isThinEnabled
Indicates whether to enable thin provisioning for file system. Default is $True
.PARAMETER Size
Filesystem Size
.PARAMETER hostIOSize
Typical write I/O size from the host to the file system
.PARAMETER isCacheDisabled
Indicates whether caching is disabled
.PARAMETER accessPolicy
Access policy
.PARAMETER poolFullPolicy
Behavior to follow when pool is full and a write to this filesystem is attempted
.PARAMETER tieringPolicy
Filesystem tiering policy
.PARAMETER isCIFSSyncWritesEnabled
Indicates whether the CIFS synchronous writes option is enabled for the file system
.PARAMETER isCIFSOpLocksEnabled
Indicates whether opportunistic file locks are enabled for the file system
.PARAMETER isCIFSNotifyOnWriteEnabled
Indicates whether the system generates a notification when the file system is written to
.PARAMETER isCIFSNotifyOnAccessEnabled
Indicates whether the system generates a notification when a user accesses the file system
.PARAMETER cifsNotifyOnChangeDirDepth
Indicates the lowest directory level to which the enabled notifications apply, if any
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
New-UnityFilesystem -Name 'FS01' -Pool 'pool_1' -Size 10GB -nasServer 'nas_1' -supportedProtocols 'CIFS'
Create CIFS filesystem named 'FS01' on pool 'pool_1' and with a size of '10GB' bytes
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
#Default Parameters
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
#CreateFilesystem
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Filesystem Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,HelpMessage = 'Filesystem Description')]
[String]$Description,
[Parameter(Mandatory = $false,HelpMessage = 'ID of a protection schedule to apply to the filesystem')]
[String]$snapSchedule,
[Parameter(Mandatory = $false,HelpMessage = 'Is assigned snapshot schedule is paused ? (Default is false)')]
[bool]$isSnapSchedulePaused = $false,
#fsParameters
[Parameter(Mandatory = $true,HelpMessage = 'Filesystem Pool ID')]
[String]$Pool,
[Parameter(Mandatory = $true,HelpMessage = 'Filesystem nasServer ID')]
[String]$nasServer,
[Parameter(Mandatory = $true,HelpMessage = 'Filesystem supported protocols')]
[FSSupportedProtocolEnum]$supportedProtocols,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether File Level Retention (FLR) is enabled for the file system')]
[String]$isFLREnabled = $false,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether to enable thin provisioning for file system')]
[String]$isThinEnabled = $true,
[Parameter(Mandatory = $true,HelpMessage = 'Filesystem Size')]
[uint64]$Size,
[Parameter(Mandatory = $false,HelpMessage = 'Typical write I/O size from the host to the file system')]
[HostIOSizeEnum]$hostIOSize,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether caching is disabled')]
[bool]$isCacheDisabled,
[Parameter(Mandatory = $false,HelpMessage = 'Access policy')]
[AccessPolicyEnum]$accessPolicy,
[Parameter(Mandatory = $false,HelpMessage = 'Behavior to follow when pool is full and a write to this filesystem is attempted')]
[ResourcePoolFullPolicyEnum]$poolFullPolicy,
##fastVPParameterseters
[Parameter(Mandatory = $false,HelpMessage = 'Filesystem tiering policy')]
[TieringPolicyEnum]$tieringPolicy,
#cifsFilesystemParameters
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether the CIFS synchronous writes option is enabled for the file system')]
[bool]$isCIFSSyncWritesEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether opportunistic file locks are enabled for the file system')]
[bool]$isCIFSOpLocksEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether the system generates a notification when the file system is written to')]
[bool]$isCIFSNotifyOnWriteEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether the system generates a notification when a user accesses the file system')]
[bool]$isCIFSNotifyOnAccessEnabled,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates the lowest directory level to which the enabled notifications apply, if any')]
[int]$cifsNotifyOnChangeDirDepth
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
## Variables
$URI = '/api/types/storageResource/action/createFilesystem'
$Type = 'Filesystem'
$StatusCode = 200
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
Foreach ($n in $Name) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
# Name parameter
$body["name"] = "$($n)"
# Domain parameter
If ($Description) {
$body["description"] = "$($Description)"
}
# fsParameters parameter
$body["fsParameters"] = @{}
$fsParameters = @{}
$poolParameters = @{}
$poolParameters["id"] = "$($Pool)"
$fsParameters["pool"] = $poolParameters
$nasServerParameters = @{}
$nasServerParameters["id"] = "$($nasServer)"
$fsParameters["nasServer"] = $nasServerParameters
$fsParameters["size"] = $($Size)
$fsParameters["supportedProtocols"] = $($supportedProtocols)
# isFLREnabled
If ($PSBoundParameters.ContainsKey('isFLREnabled')) {
$fsParameters["isFLREnabled"] = $isFLREnabled
}
# isThinEnabled
If ($PSBoundParameters.ContainsKey('isThinEnabled')) {
$fsParameters["isThinEnabled"] = $isThinEnabled
}
# hostIOSize
If ($PSBoundParameters.ContainsKey('hostIOSize')) {
$fsParameters["hostIOSize"] = $hostIOSize
}
# fastVPParameters
If ($PSBoundParameters.ContainsKey('tieringPolicy')) {
$fastVPParameters = @{}
$fastVPParameters['tieringPolicy'] = $tieringPolicy
$fsParameters["fastVPParameters"] = $fastVPParameters
}
# isCacheDisabled
If ($PSBoundParameters.ContainsKey('isCacheDisabled')) {
$fsParameters["isThinEnabled"] = $isCacheDisabled
}
# accessPolicy
If ($PSBoundParameters.ContainsKey('accessPolicy')) {
$fsParameters["accessPolicy"] = $accessPolicy
}
# poolFullPolicy
If ($PSBoundParameters.ContainsKey('poolFullPolicy')) {
$fsParameters["poolFullPolicy"] = $poolFullPolicy
}
$body["fsParameters"] = $fsParameters
IF (($PSBoundParameters.ContainsKey('isCIFSSyncWritesEnabled')) -or ($PSBoundParameters.ContainsKey('isCIFSOpLocksEnabled')) -or ($PSBoundParameters.ContainsKey('isCIFSNotifyOnWriteEnabled')) -or ($PSBoundParameters.ContainsKey('isCIFSNotifyOnAccessEnabled')) -or ($PSBoundParameters.ContainsKey('cifsNotifyOnChangeDirDepth'))) {
$body["cifsFsParameters"] = @{}
$cifsFsParameters = @{}
# isCIFSSyncWritesEnabled
If ($PSBoundParameters.ContainsKey('isCIFSSyncWritesEnabled')) {
$fsParameters["isCIFSSyncWritesEnabled"] = $isCIFSSyncWritesEnabled
}
# isCIFSOpLocksEnabled
If ($PSBoundParameters.ContainsKey('isCIFSOpLocksEnabled')) {
$fsParameters["isCIFSOpLocksEnabled"] = $isCIFSOpLocksEnabled
}
# isCIFSNotifyOnWriteEnabled
If ($PSBoundParameters.ContainsKey('isCIFSNotifyOnWriteEnabled')) {
$fsParameters["isCIFSNotifyOnWriteEnabled"] = $isCIFSNotifyOnWriteEnabled
}
# isCIFSNotifyOnAccessEnabled
If ($PSBoundParameters.ContainsKey('isCIFSNotifyOnAccessEnabled')) {
$fsParameters["isCIFSNotifyOnAccessEnabled"] = $isCIFSNotifyOnAccessEnabled
}
# cifsNotifyOnChangeDirDepth
If ($PSBoundParameters.ContainsKey('cifsNotifyOnChangeDirDepth')) {
$fsParameters["cifsNotifyOnChangeDirDepth"] = $cifsNotifyOnChangeDirDepth
}
$body["cifsFsParameters"] = $cifsFsParameters
}
#snapScheduleParameters
If ($snapSchedule) {
$body["snapScheduleParameters"] = @{}
$snapScheduleParameters = @{}
$snapScheduleParam = @{}
$snapScheduleParam["id"] ="$($snapSchedule)"
$snapScheduleParameters["snapSchedule"] = $snapScheduleParam
$snapScheduleParameters["isSnapSchedulePaused"]= "$($isSnapSchedulePaused)"
$body["snapScheduleParameters"] = $snapScheduleParameters
}
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
##Building the URL
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Create $Type $n")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
Write-Verbose "Request status code: $($request.StatusCode)"
If ($request.StatusCode -eq $StatusCode) {
#Formating the result. Converting it from JSON to a Powershell object
$results = ($request.content | ConvertFrom-Json).content
$Storageresource = Get-UnitystorageResource -session $Sess -ID $results.storageResource.id
Write-Verbose "$Type with the ID $($Storageresource.Filesystem.id) has been created"
Get-UnityFilesystem -Session $Sess -ID $Storageresource.Filesystem.id
} # End If ($request.StatusCode -eq $StatusCode)
} # End If ($Sess.TestConnection())
} # End Foreach
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
PowerShellCorpus/PowerShellGallery/Unity-Powershell/0.14.2/Public/New-UnityLUN.ps1
|
New-UnityLUN.ps1
|
Function New-UnityLUN {
<#
.SYNOPSIS
Creates a Unity block LUN.
.DESCRIPTION
Creates a Unity block LUN.
You need to have an active session with the array.
.NOTES
Written by Erwan Quelin under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
.LINK
https://github.com/equelin/Unity-Powershell
.PARAMETER Session
Specify an UnitySession Object.
.PARAMETER Name
Name of the LUN unique to the system.
.PARAMETER Pool
Pool ID
.PARAMETER Description
Description of the LUN.
.PARAMETER Size
LUN Size.
.PARAMETER fastVPParameters
FAST VP settings for the storage resource
.PARAMETER isCompressionEnabled
Indicates whether to enable inline compression for the LUN. Default is True on compatible arrays
.PARAMETER isThinEnabled
Is Thin enabled on LUN ? (Default is true)
.PARAMETER host
List of host to grant access to LUN.
.PARAMETER accessMask
Host access mask. Might be:
- NoAccess: No access.
- Production: Access to production LUNs only.
- Snapshot: Access to LUN snapshots only.
- Both: Access to both production LUNs and their snapshots.
.PARAMETER snapSchedule
Snapshot schedule settings for the LUN, as defined by the snapScheduleParameters.
.PARAMETER isSnapSchedulePaused
Indicates whether the assigned snapshot schedule is paused.
.PARAMETER Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.
.PARAMETER WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.
.EXAMPLE
New-UnityLUN -Name 'DATASTORE01' -Pool 'pool_1' -Size 10GB -host 'Host_12' -accessMask 'Production'
Create LUN named 'LUN01' on pool 'pool_1' and with a size of '10GB', grant production access to 'Host_12'
#>
[CmdletBinding(SupportsShouldProcess = $True,ConfirmImpact = 'High')]
Param (
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'LUN Name')]
[String[]]$Name,
[Parameter(Mandatory = $false,HelpMessage = 'LUN Description')]
[String]$Description,
# lunParameters
[Parameter(Mandatory = $true,HelpMessage = 'LUN Pool ID')]
[String]$Pool,
[Parameter(Mandatory = $true,HelpMessage = 'LUN Size in Bytes')]
[uint64]$Size,
[Parameter(Mandatory = $false,HelpMessage = 'Host to grant access to LUN')]
[String[]]$host,
[Parameter(Mandatory = $false,HelpMessage = 'Host access mask')]
[HostLUNAccessEnum]$accessMask = 'Production',
[Parameter(Mandatory = $false,HelpMessage = 'Is Thin enabled on LUN ? (Default is true)')]
[bool]$isThinEnabled = $true,
[Parameter(Mandatory = $false,HelpMessage = 'FAST VP settings for the storage resource')]
[TieringPolicyEnum]$fastVPParameters,
[Parameter(Mandatory = $false,HelpMessage = 'Indicates whether to enable inline compression for the LUN. Default is True')]
[bool]$isCompressionEnabled,
# snapScheduleParameters
[Parameter(Mandatory = $false,HelpMessage = 'ID of a protection schedule to apply to the storage resource')]
[String]$snapSchedule,
[Parameter(Mandatory = $false,HelpMessage = 'Is assigned snapshot schedule is paused ? (Default is false)')]
[bool]$isSnapSchedulePaused = $false
)
Begin {
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
## Variables
$URI = '/api/types/storageResource/action/createLun'
$Type = 'LUN'
$StatusCode = 200
}
Process {
Foreach ($sess in $session) {
Write-Debug -Message "Processing Session: $($sess.Server) with SessionId: $($sess.SessionId)"
Foreach ($n in $Name) {
#### REQUEST BODY
# Creation of the body hash
$body = @{}
# Name parameter
$body["name"] = "$($n)"
# Domain parameter
If ($Description) {
$body["description"] = "$($Description)"
}
# lunParameters parameter
$body["lunParameters"] = @{}
$lunParameters = @{}
$poolParameters = @{}
$poolParameters["id"] = "$($Pool)"
$lunParameters["pool"] = $poolParameters
$lunParameters["size"] = $($Size)
If ($PSBoundParameters.ContainsKey('fastVPParameters')) {
$lunParameters["fastVPParameters"] = @{}
$fastVPParam = @{}
$fastVPParam['tieringPolicy'] = $fastVPParameters
$lunParameters["fastVPParameters"] = $fastVPParam
}
If ($PSBoundParameters.ContainsKey('isCompressionEnabled')) {
$lunParameters["isCompressionEnabled"] = $isCompressionEnabled
} else {
$lunParameters["isCompressionEnabled"] = Test-CompressionUnsupported -Session $Sess -Pool $Pool
}
If ($PSBoundParameters.ContainsKey('host')) {
$lunParameters["hostAccess"] = @()
$hostAccess = @()
foreach ($h in $host) {
$blockHostAccessParam = @{}
$blockHostAccessParam['host'] = @{}
$HostParam = @{}
$HostParam['id'] = $h
$blockHostAccessParam['host'] = $HostParam
$blockHostAccessParam['accessMask'] = $accessMask
$hostAccess += $blockHostAccessParam
}
$lunParameters["hostAccess"] = $hostAccess
}
$body["lunParameters"] = $lunParameters
#snapScheduleParameters
If ($snapSchedule) {
$body["snapScheduleParameters"] = @{}
$snapScheduleParameters = @{}
$snapScheduleParam = @{}
$snapScheduleParam["id"] ="$($snapSchedule)"
$snapScheduleParameters["snapSchedule"] = $snapScheduleParam
$snapScheduleParameters["isSnapSchedulePaused"]= "$($isSnapSchedulePaused)"
$body["snapScheduleParameters"] = $snapScheduleParameters
}
# isThinEnabled
If ($PSBoundParameters.ContainsKey('isThinEnabled')) {
$lunParameters["isThinEnabled"] = $isThinEnabled
}
$body["lunParameters"] = $lunParameters
####### END BODY - Do not edit beyond this line
#Show $body in verbose message
$Json = $body | ConvertTo-Json -Depth 10
Write-Verbose $Json
If ($Sess.TestConnection()) {
##Building the URL
$URL = 'https://'+$sess.Server+$URI
Write-Verbose "URL: $URL"
#Sending the request
If ($pscmdlet.ShouldProcess($Sess.Name,"Create $Type $n")) {
$request = Send-UnityRequest -uri $URL -Session $Sess -Method 'POST' -Body $Body
}
Write-Verbose "Request status code: $($request.StatusCode)"
If ($request.StatusCode -eq $StatusCode) {
#Formating the result. Converting it from JSON to a Powershell object
$results = ($request.content | ConvertFrom-Json).content
$Storageresource = Get-UnitystorageResource -session $Sess -ID $results.storageResource.id
Write-Verbose "$Type with the ID $($Storageresource.luns.id) has been created"
Get-UnityLUN -Session $Sess -ID $Storageresource.luns.id
} # End If ($request.StatusCode -eq $StatusCode)
} # End If ($Sess.TestConnection())
} # End Foreach
} # End Foreach ($sess in $session)
} # End Process
} # End Function
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.