<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: OCUM - how to extract all active events? in ONTAP Discussions</title>
    <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148726#M33098</link>
    <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://community.netapp.com/t5/user/viewprofilepage/user-id/2305"&gt;@mbeattie&lt;/a&gt;&amp;nbsp;!&amp;nbsp; That is exactly what I needed.&amp;nbsp; Took me a little while to figure out what you were doing, but I think the&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;.GetNetworkCredential().&lt;/PRE&gt;
&lt;P&gt;was the piece I was missing.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jun 2019 17:05:39 GMT</pubDate>
    <dc:creator>Jim_Robertson</dc:creator>
    <dc:date>2019-06-05T17:05:39Z</dc:date>
    <item>
      <title>OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147015#M32709</link>
      <description>&lt;P&gt;Hello, dear All &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am a newbie in the NetApp world and we are moving from EMC to NetApp.&lt;/P&gt;
&lt;P&gt;I would like to know everyting about issues/problems with our systems and I need to transfer all (possible) events to our CA NIMSOFT Dashboards. So, I have OCUM installed on Windows 2012 R2 server. Everything is working fine, and I want to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Connect to OCUM via PowerShell and read events (preffered)&lt;/P&gt;
&lt;P&gt;- Connect to OCUM's REST API and read events (via PowerShell too, I hope)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any other idea like sending e-mails or SNMP traps is "not my cup of tea" so....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So. The first item in my list is seems difficult. I did not find any PS module for OCUM 9.5&lt;/P&gt;
&lt;P&gt;The second is much better, but...&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to know how can I create a link that contains REST API command AND user name and password.&lt;/P&gt;
&lt;P&gt;Because the main OCUM's web page is not providing a form for previding user name and password, I cannot connect to OCUM via "stantard" approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can somebody help me?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 12:45:13 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147015#M32709</guid>
      <dc:creator>rome</dc:creator>
      <dc:date>2025-06-04T12:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147027#M32712</link>
      <description>&lt;P&gt;I would look at CA's plugins.&amp;nbsp; You do not necessarily need to read OCUM, as that will give you RBAC and Performance metrics.&amp;nbsp; NetApp can trap errors, however, the best solution is to use the CA plugin for ONTAP.&lt;/P&gt;
&lt;P&gt;So here is what I think you should look at in order of preference for events, if you can't get the plugin:&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp; Use OCUM's Events Dashboard;&amp;nbsp; it is a very good Event notifier, although only for NetApp&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; Use email in OCUM to send event alerts to the CA product&lt;/P&gt;
&lt;P&gt;3. Trying to use the rest will be very difficult.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 22:54:44 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147027#M32712</guid>
      <dc:creator>Tas</dc:creator>
      <dc:date>2019-03-11T22:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147037#M32714</link>
      <description>&lt;P&gt;Thank you very much for your answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, CA's netapp probe leaves to be desired (like vmware too...)&lt;/P&gt;
&lt;P&gt;Using PowerCLI I build a little script that moves ESXi alarms to the SQL table and then I show them on the dashboards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using emails is not a solution because we (do not laught!) do not use internal email server and we are "black site"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using OCUM's dashboard is beautiful solution for me, but not for all our team. And, of course, we would like to stare on one dashbaord instead of tousands &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, for me if much simpler to use PowerShell and bring events/alarms streight to dashboards.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2019 13:12:49 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147037#M32714</guid>
      <dc:creator>rome</dc:creator>
      <dc:date>2019-03-12T13:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147050#M32717</link>
      <description>&lt;P&gt;I am not a PS guy but I guess this should help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Curl:&lt;/P&gt;
&lt;DIV class="block curl"&gt;
&lt;PRE&gt;curl -u username:password -X GET --header 'Accept: application/vnd.netapp.object.inventory.hal+json' 'https://&lt;STRONG&gt;&amp;lt;OCUM_Server&amp;gt;&lt;/STRONG&gt;/rest/events?limit=20'&lt;/PRE&gt;
&lt;P&gt;PS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;add-type @"&lt;BR /&gt;using System.Net;&lt;BR /&gt;using System.Security.Cryptography.X509Certificates;&lt;BR /&gt;public class TrustAllCertsPolicy : ICertificatePolicy {&lt;BR /&gt;public bool CheckValidationResult(&lt;BR /&gt;ServicePoint srvPoint, X509Certificate certificate,&lt;BR /&gt;WebRequest request, int certificateProblem) {&lt;BR /&gt;return true;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;"@&lt;BR /&gt;[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy&lt;/P&gt;
&lt;P&gt;&amp;lt;# Above code will Ignore Certificates #&amp;gt;&lt;/P&gt;
&lt;P&gt;$Username = 'Username'&lt;BR /&gt;$Password = 'Password'&lt;BR /&gt;$pass = ConvertTo-SecureString -AsPlainText $Password -Force&lt;BR /&gt;$Cred = New-Object System.Management.Automation.PSCredential($Username,$pass)&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;$response = Invoke-RestMethod 'https://nc2twnaocum01/rest/events?limit=20' -Credential $Cred -Method Get&lt;BR /&gt;echo $response&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 12 Mar 2019 17:35:23 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147050#M32717</guid>
      <dc:creator>gaurav_verma</dc:creator>
      <dc:date>2019-03-12T17:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147054#M32719</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Wow! Thank you very much! &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Tomorrow I'll check this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2019 19:06:43 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147054#M32719</guid>
      <dc:creator>rome</dc:creator>
      <dc:date>2019-03-12T19:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147074#M32725</link>
      <description>&lt;P&gt;Hm....&lt;/P&gt;
&lt;P&gt;I got an error &lt;STRONG&gt;401 - Unauthorized,&amp;nbsp;&lt;/STRONG&gt;despite I provided credentials and they are OK when I log in via web.&lt;/P&gt;
&lt;P&gt;Any suggestions?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 06:53:50 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147074#M32725</guid>
      <dc:creator>rome</dc:creator>
      <dc:date>2019-03-13T06:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147092#M32728</link>
      <description>&lt;P&gt;&lt;a href="https://community.netapp.com/t5/user/viewprofilepage/user-id/75892"&gt;@rome&lt;/a&gt;&amp;nbsp; I suggest to test it first with Postman (&lt;A href="https://www.getpostman.com/).&amp;nbsp;" target="_blank"&gt;https://www.getpostman.com/).&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If you are using your user name with domain (domain\username), I suggest do not use domain name as OCUM does not allow domain name some time.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 12:07:35 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147092#M32728</guid>
      <dc:creator>gaurav_verma</dc:creator>
      <dc:date>2019-03-13T12:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147784#M32903</link>
      <description>&lt;P&gt;This is THE solution.&lt;/P&gt;
&lt;P&gt;Sorry, without comments but it is simle enough:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;cls


function Convert-FromUnixDate ($UnixDate)
{
    [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddMilliseconds($UnixDate))
}


Add-Type @"
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;
}
}
"@
$AllProtocols = [System.Net.SecurityProtocolType]'Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy


Import-Module SQLPS -DisableNameChecking

$DatabaseName = 'dbname'
$DatabaseUserName = 'username'
$DatabasePassword = 'password'
$DatabaseServerInstance = 'server.domain.org\dom,1436'


$username="monitoring"
$pass = "monitoring"
$password = ConvertTo-SecureString -AsPlainText $pass -Force


$bytes = [System.Text.Encoding]::UTF8.GetBytes("$username`:$pass")
$encodedCredentials = [System.Convert]::ToBase64String($bytes)
$headers = @{
"Authorization" = "Basic " + $encodedCredentials
"Accept" = "application/vnd.netapp.object.inventory.hal+json"
}

$events = Invoke-RestMethod  -Headers $headers -Uri https://ocum.domain.org/rest/events?limit=9999999


$query = 'DELETE FROM [dbname].[dbo].[NetApp]'
Invoke-Sqlcmd -Database $DatabaseName -Username $DatabaseUserName -Password $DatabasePassword -Query $Query -ServerInstance $DatabaseServerInstance


foreach ($event in $events._embedded."netapp:eventDtoList")
{
    Write-Host $event.name - $event.conditionMessage
    
    $query = "INSERT INTO [dbname].[dbo].[NetApp] 
    (
    objectId,
    name, 
    conditionMessage, 
    timestamp, 
    severity, 
    impactArea, 
    impactLevel, 
    sourceFullName, 
    state, 
    resolvedTimestamp, 
    resolvedBy,
    acknowledgedTimestamp,
    acknowledgedBy,
    sourceResourceType,
    daysOutstanding
    ) 
    values   
    (
    '$($event.objectId)',
    '$($event.name)',
    '$($event.conditionMessage -replace "'", """)',
    '$(Convert-FromUnixDate ($event.timestamp))',
    '$($event.severity)',
    '$($event.impactArea)',
    '$($event.impactLevel)',
    '$($event.sourceFullName)',
    '$($event.state)',
    '$(Convert-FromUnixDate ($event.resolvedTimestamp))',
    '$($event.resolvedBy)',
    '$(Convert-FromUnixDate ($event.acknowledgedTimestamp))',
    '$($event.acknowledgedBy)',
    '$($event.sourceResourceType)',
    '$($event.daysOutstanding)'
    )
    "
    #Write-Host $query
    Write-Host
    Invoke-Sqlcmd -Database $DatabaseName -Username $DatabaseUserName -Password $DatabasePassword -Query $Query -ServerInstance $DatabaseServerInstance

}


$username = 'user'
$pass = 'password'
$password = ConvertTo-SecureString ($pass) -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($username, $password)
Connect-NcController -Credential $cred -name 172.17.114.150

$volumes = Get-NcVol
foreach ($volume in $volumes)
{    
    $lastSnapshotDate = Get-NcSnapshot -Volume $volume | Sort-Object Created | Select-Object Created, Name -Last 1 
    
    $dateNow = (Get-Date).AddDays(0)
    
    $timeSpan = 1

    if ($volume.Name -eq 'data_CIFS_volume' -or $volume.Name -eq 'nvrvideo_CIFS_volume')    {        $timeSpan = 7    }

       
    if ((New-TimeSpan -Start $lastSnapshotDate.Created -End $dateNow).Days -gt $timeSpan)
    {                
        $lastSnaphotErrorString = "The last snapshot of the volume `"$volume`" was created at $(($lastSnapshotDate.Created).ToString(`"dd/MM/yyyy,`")) $((New-TimeSpan -Start $lastSnapshotDate.Created -End $dateNow).Days) days ago"
        Write-host $lastSnaphotErrorString 

        $query = "INSERT INTO [dbname].[dbo].[NetApp] 
        (
        objectId,
        name, 
        conditionMessage, 
        timestamp, 
        severity, 
        impactArea, 
        impactLevel, 
        sourceFullName, 
        state, 
        resolvedTimestamp, 
        resolvedBy,
        acknowledgedTimestamp,
        acknowledgedBy,
        sourceResourceType,
        daysOutstanding
        ) 
        values   
        (
        '-1',
        'Last snapshot',
        '$lastSnaphotErrorString',
        null,
        'error',
        null,
        null,
        '$volume',
        'NEW',
        null,
        null,
        null,
        null,
        null,
        null
        )
        "    
        Invoke-Sqlcmd -Database $DatabaseName -Username $DatabaseUserName -Password $DatabasePassword -Query $Query -ServerInstance $DatabaseServerInstance
    } 
    
}


&amp;lt;#




SELECT objectId , 'NetApp ' + sourceFullName + ': ' + name + ': ' + conditionMessage as message FROM [dbname].[dbo].[NetApp] where state = 'NEW' and severity &amp;lt;&amp;gt; 'information'


----------------------------------------------------------------------------------------------------------

  USE [dbname]
GO

/****** Object:  Table [dbo].[NetApp]    Script Date: 3/26/2019 12:22:40 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[NetApp](
	[objectId] [int] NULL,
	[name] [nvarchar](max) NULL,
	[conditionMessage] [nvarchar](max) NULL,
	[timestamp] [datetime] NULL,
	[severity] [nchar](15) NULL,
	[impactArea] [nchar](15) NULL,
	[impactLevel] [nchar](10) NULL,
	[sourceFullName] [nvarchar](max) NULL,
	[state] [nvarchar](50) NULL,
	[resolvedTimestamp] [datetime] NULL,
	[resolvedBy] [nvarchar](50) NULL,
	[acknowledgedTimestamp] [datetime] NULL,
	[acknowledgedBy] [nvarchar](50) NULL,
	[sourceResourceType] [nvarchar](50) NULL,
	[daysOutstanding] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
----------------------------------------------------------------------------------------------------------


#&amp;gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Apr 2019 13:41:33 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/147784#M32903</guid>
      <dc:creator>rome</dc:creator>
      <dc:date>2019-04-07T13:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148658#M33083</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.netapp.com/t5/user/viewprofilepage/user-id/75892"&gt;@rome&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;$username="monitoring"
$pass = "monitoring"
$password = ConvertTo-SecureString -AsPlainText $pass -Force

$bytes = [System.Text.Encoding]::UTF8.GetBytes("$username`:$pass")
$encodedCredentials = [System.Convert]::ToBase64String($bytes)&lt;BR /&gt;
$headers = @{
"Authorization" = "Basic " + $encodedCredentials
"Accept" = "application/vnd.netapp.object.inventory.hal+json"
}
&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thanks for posting this, this was a huge help.&amp;nbsp; I was able to get it working with the code you have posted, but I was wondering if there was a way to do this without having the password in clear text in the code?&amp;nbsp; I've tried putting the password into a secure file.&amp;nbsp; i.e.:&lt;BR /&gt;&lt;BR /&gt;Read-Host -assecurestring -Prompt 'Password' | convertfrom-securestring | out-file C:\cred.txt&lt;BR /&gt;$pass = get-content C:\cred.txt | convertto-securestring&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;But, when I convert it to a secure string, it messes up the encoding.&amp;nbsp; I want to have this run as an automated process, and there is no way that I can have a password hard coded into it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 18:49:30 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148658#M33083</guid>
      <dc:creator>Jim_Robertson</dc:creator>
      <dc:date>2019-05-31T18:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148668#M33084</link>
      <description>&lt;P&gt;Hi Jim,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an "example" you can use a PowerShell credential object as an input paramater.&lt;/P&gt;
&lt;P&gt;If invoking an OCUM REST API from WFA you can use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;$credentials = Get-WfaCredentials $ocumIp&lt;/PRE&gt;
&lt;P&gt;If you just want to run a PowerShell script that accepts a Credential object as an input paramater, the following example enables you to query OCUM events for the past X hours:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Param(
   [Parameter(Mandatory=$True, HelpMessage="The OCUM server's hostname or IP Address")]   
   [String]$Hostname,
   [Parameter(Mandatory=$True, HelpMessage="The number of hours to enumerate OCUM events for")]   
   [Int]$EventRangeHours,
   [Parameter(Mandatory=$True, HelpMessage="The OCUM credentials used to authenticate the REST API request")]
   [System.Management.Automation.PSCredential]$Credentials
)
Add-Type @"
   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;
   }
}
"@
[String]$username = $Credentials.GetNetworkCredential().UserName
[String]$password = $Credentials.GetNetworkCredential().Password
[System.Net.ServicePointManager]::SecurityProtocol  = [System.Net.SecurityProtocolType]'Tls12'
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("$username`:$password"))
$headers = @{
   "Authorization" = "Basic " + $encodedCredentials
   "Accept"        = "application/vnd.netapp.object.inventory.hal+json"
}
[String]$uri = $("https://$HostName/rest/events?triggeredTime=LAST`_" + $EventRangeHours + "h")
Try{
   $events = Invoke-RestMethod -Headers $headers -Uri $uri -ErrorAction Stop
   Write-Host "Enumerated OCUM events within the past $EventRangeHours hours using URI ""$uri"""
}Catch{
   Write-Warning -Message $("Failed enumerating OCUM Events within the past $EventRangeHours hours using URI ""$uri"". Error " + $_.Exception.Message)
   Break;
}
ForEach($event In $events._embedded.'netapp:eventDtoList'){
   $event
}&lt;/PRE&gt;
&lt;P&gt;Hope that helps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/Matt&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 01:17:22 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148668#M33084</guid>
      <dc:creator>mbeattie</dc:creator>
      <dc:date>2019-06-03T01:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148726#M33098</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://community.netapp.com/t5/user/viewprofilepage/user-id/2305"&gt;@mbeattie&lt;/a&gt;&amp;nbsp;!&amp;nbsp; That is exactly what I needed.&amp;nbsp; Took me a little while to figure out what you were doing, but I think the&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;.GetNetworkCredential().&lt;/PRE&gt;
&lt;P&gt;was the piece I was missing.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 17:05:39 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148726#M33098</guid>
      <dc:creator>Jim_Robertson</dc:creator>
      <dc:date>2019-06-05T17:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148730#M33101</link>
      <description>&lt;P&gt;Hi Jim,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes that's it, use the .GetNetworkCredential() method of the [System.Management.Automation.PSCredential]. If you don't want to pass credentials as an input paramater (IE you running your script on a server as a scheduled task then you can cache and encrypt the credentials either locally to a file or to the registry then decrypt the credentials using the Windows Data Protection API). I can post an example if that's what you are trying to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/Matt&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 22:54:21 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148730#M33101</guid>
      <dc:creator>mbeattie</dc:creator>
      <dc:date>2019-06-05T22:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148763#M33102</link>
      <description>&lt;P&gt;&lt;a href="https://community.netapp.com/t5/user/viewprofilepage/user-id/2305"&gt;@mbeattie&lt;/a&gt;&amp;nbsp;, yep, that is exactly what I'm trying to do.&amp;nbsp; I got it working, but if you have a different way of doing it, I would be interested in seeing it.&amp;nbsp; For the record, I'm just trying to pull a list of clusters that are in OCUM.&amp;nbsp; I thought it would be a good way to pull a list of controllers to run PS scripts against, since all active controllers should always be added to OCUM once they are in production.&lt;BR /&gt;&lt;BR /&gt;So, I first created a secure password file:&lt;/P&gt;
&lt;PRE&gt;(Get-Credential).Password | ConvertFrom-SecureString | Out-File "C:\OCUM-Password.txt"&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Then I create a PS object from that in line 4.&amp;nbsp; Then use the Get-NetCredential to pull the password from the PS Credentials like in your example.&lt;/P&gt;
&lt;PRE&gt;$url = "https://ocum-server-dns/rest/clusters?limit=200"
$User = "ocum-admin"
$File = "C:\OCUM-Password.txt"
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, (Get-Content $File | ConvertTo-SecureString)

# Ignore certificate requests from OCUM server
Add-Type @"
   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;
   }
}
"@
[String]$username = $Credentials.GetNetworkCredential().UserName
[String]$password = $Credentials.GetNetworkCredential().Password

[System.Net.ServicePointManager]::SecurityProtocol  = [System.Net.SecurityProtocolType]'Tls12'
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("$username`:$password"))
$headers = @{
   "Authorization" = "Basic " + $encodedCredentials
   "Accept"        = "application/vnd.netapp.object.inventory.hal+json"
}

$clusters = Invoke-RestMethod  -Headers $headers -Uri $url

foreach ($cluster in $clusters._embedded."netapp:clusterInventoryList")
{
    Write-Host $cluster.cluster.label
}

&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;The only downside I am seeing right now is that the password file will only be readable by me on the server that I created it on (at least that is my understanding from what I've read).&amp;nbsp; If I want others to be able to read it, it's looking like I will have to setup a secure key for the file.&lt;BR /&gt;&lt;BR /&gt;Thanks again!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2019 13:49:42 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148763#M33102</guid>
      <dc:creator>Jim_Robertson</dc:creator>
      <dc:date>2019-06-06T13:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: OCUM - how to extract all active events?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148772#M33104</link>
      <description>&lt;P&gt;Hi Jim,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are a few options:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Encrypt credentials to a file&lt;/LI&gt;
&lt;LI&gt;Encrypt credentials to the registry&lt;/LI&gt;
&lt;LI&gt;Cache credentials using "Add-NcCredential" (See Get-Help Add-NcCredentials)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Here is an example using the cached credential method demonstrating how to add and retrieve credentials from the cache.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Param(
   [Parameter(Mandatory=$True, HelpMessage="The hostname, IP Address or FQDN of the system to cache credentials for")]
   [String]$HostName
)
#'------------------------------------------------------------------------------
#'Add credentials to the cache.
#'------------------------------------------------------------------------------
Import-Module -Name DataONTAP -ErrorAction SilentlyContinue
Try{
   Add-NcCredential -Name $HostName -Credential $(Get-Credential) -ErrorAction Stop
   Write-Host "Added Credentials for ""$HostName"""
}Catch{
   Write-Warning -Message $("Failed Adding Credentials for ""$HostName"". Error " + $_.Exception.Message)&lt;BR /&gt;   Break;
}
#'------------------------------------------------------------------------------
#'Enumerate the credentials from the cache.
#'------------------------------------------------------------------------------
Try{
   $credentials = Get-NcCredential -Name $HostName -ErrorAction Stop
}Catch{
   Write-Warning -Message $("Failed enumerating Credentials for ""$HostName"". Error " + $_.Exception.Message)
   Break;
}
[String]$username = $credentials.Credential.GetNetworkCredential().UserName
[String]$password = $credentials.Credential.GetNetworkCredential().Password
Write-Host "Username`: $username. Password`: $password"
#'------------------------------------------------------------------------------&lt;/PRE&gt;
&lt;P&gt;Encrypting credentials to the registry is slightly more abstracted and offers some advantage to encrypting to a file (IE it avoids risk of the credential file being accidently deleted and your automation potentially failing as a result of a missing credential file). Caching credentials using the PSTK is the simplest method. If you don't have the Data ONTAP powershell toolkit (PSTK) you can download it here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="https://mysupport.netapp.com/tools/info/ECMLP2310788I.html?productID=61926&amp;amp;pcfContentID=ECMLP2310788" href="https://mysupport.netapp.com/tools/info/ECMLP2310788I.html?productID=61926&amp;amp;pcfContentID=ECMLP2310788" target="_blank" rel="noopener"&gt;https://mysupport.netapp.com/tools/info/ECMLP2310788I.html?productID=61926&amp;amp;pcfContentID=ECMLP2310788&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that's useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/Matt&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 03:14:03 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/OCUM-how-to-extract-all-active-events/m-p/148772#M33104</guid>
      <dc:creator>mbeattie</dc:creator>
      <dc:date>2019-06-07T03:14:03Z</dc:date>
    </item>
  </channel>
</rss>

