<Discovery ID="PureStorage.FlashArray.PureArray.Discovery" Target="PureStorage.FlashArray.PureArray" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="PureStorage.FlashArray.PureArray">
<Property PropertyID="Endpoint"/>
<Property PropertyID="ArrayName"/>
<Property PropertyID="ApiVersion"/>
<Property PropertyID="Role"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="PSDiscovery" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>3600</IntervalSeconds>
<SyncTime/>
<ScriptName>PureArrayDiscovery.ps1</ScriptName>
<ScriptBody><Script># This script looks for a credentials file and attempt to connect to a FlashArray.
# On success, it populates the properties of the Pure Array class.
try {
$IgnoreCertErrors = GetIgnoreCertErrors $true
$FlashArray = New-PfaArray -EndPoint $Endpoint -UserName $Username -Password $Password -ClientName $GLOBAL:clientName -ClientVersion $GLOBAL:mpVersion -IgnoreCertificateError:$IgnoreCertErrors -HttpTimeOutInMilliSeconds 60000
} catch {
Log $ScriptName $GLOBAL:ERROR_LEVEL "Connection to array failed on these credentials. $Username. Check that the PurePowershell cmdlet is installed, and your credentials are correct. Error: $_"
#$DiscoveryBag
exit
}
# Check if the $FlashArray object is valid
if ($FlashArray -eq $null) {
Log $ScriptName $GLOBAL:ERROR_LEVEL "Connection to array ($Endpoint) failed on these credentials. $Username. Check that the PurePowershell cmdlet is installed and your credentials are correct. Error: $_"
}
else {
# Acquire the information needed to construct an instance of the Pure Array class
$ArrayName = (Get-PfaArrayId -Array $FlashArray).array_name
$ApiVersion = $FlashArray.ApiVersion
$Role = $FlashArray.role
$Endpoint = $FlashArray.Endpoint
}
# Add the necessary properties to the object and add the object to the return bag
$instance = $DiscoveryBag.CreateClassInstance($ClassReference)
$instance.AddProperty("Endpoint", $Endpoint)
$instance.AddProperty("ArrayName", $ArrayName)
$instance.AddProperty("ApiVersion", $ApiVersion)
$instance.AddProperty("Role", $Role)
$DiscoveryBag.AddInstance($instance)
Disconnect-PfaArray $FlashArray
Log $ScriptName $GLOBAL:INFO_LEVEL "Discovery script Pure Array object created: $ArrayName with APIVersion $ApiVersion"
$FlashArray = $null
$ArrayName = $null
$ApiVersion = $null
$Role = $null
$EndTime = Get-Date
$ScriptTime = ($EndTime - $StartTime).TotalSeconds
Log $ScriptName $GLOBAL:INFO_LEVEL "Script has completed. Runtime was ($ScriptTime) seconds."
$DiscoveryBag
}