<?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 SLM - PowerShell in Software Development Kit (SDK) and API Discussions</title>
    <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/SLM-PowerShell/m-p/133193#M2440</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I recently installed SLM and found all the example code was in Perl\Python\Ruby. A good example can be found here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://netapp.io/2017/07/19/provision-storage-like-service-provider-netapp-service-level-manager/" target="_blank"&gt;http://netapp.io/2017/07/19/provision-storage-like-service-provider-netapp-service-level-manager/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Having that example code is great but it probably doesnt help all our windows customers out there...&lt;/P&gt;&lt;P&gt;So i thought it might be helpful to post a "very" basic example of using SLM to provision a LUN.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Whilst this example is targeting the creation of a LUN on cluster and vserver with ISCSI enabled (instead of targeting a cluster\storage service level) you get the idea (it's just an example to help you get started). One point worth noting is that i had to explicitly set TLS to version 1.1 to be able to connect to SLM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Param(
   [Parameter(Mandatory=$True, HelpMessage="The cluster name")]
   [String]$ClusterName,
   [Parameter(Mandatory=$True, HelpMessage="The lun name to create")]
   [String]$LunName,
   [Parameter(Mandatory=$True, HelpMessage="The IP Address of the SLM Server")]
   [String]$SlmIPAddress,
   [Parameter(Mandatory=$False, HelpMessage="The IP Address of the SLM Server")]
   [String]$PortNumber=8443
)
#'------------------------------------------------------------------------------
#'Ignore self signed SSL certificate on SLM server and set TLS version to 1.1
#'------------------------------------------------------------------------------
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;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls11
#'------------------------------------------------------------------------------
#'Prompt for Credentials to connect to SLM and enumerate the cluster.
#'------------------------------------------------------------------------------
$credentials = Get-Credential -Credential admin
$uri         = "https://$SlmIPAddress`:$PortNumber/api/2.0/ontap/clusters?name=$clusterName"
$result      = Invoke-RestMethod -Method Get -Uri $uri -Credential $credentials
$clusterKey  = $result.result.records.key
#'------------------------------------------------------------------------------
#'Enumerate the vserver.
#'------------------------------------------------------------------------------
$uri        = "https://$SlmIPAddress`:$PortNumber/api/2.0/ontap/storage-vms?cluster_key=$clusterKey&amp;amp;allowed_protocols=iscsi"
$result     = Invoke-RestMethod -Method Get -Uri $uri -Credential $credentials
$vserverKey = $result.result.records.key
#'------------------------------------------------------------------------------
#'Enumerate the vserver data volume.
#'------------------------------------------------------------------------------
$uri        = "https://$SlmIPAddress`:$PortNumber/api/2.0/ontap/volumes?storage_vm_key=$vserverKey&amp;amp;is_storage_vm_root=false"
$result     = Invoke-RestMethod -Method Get -Uri $uri -Credential $credentials
$volumeKey  = $result.result.records.key
$lunType    = "windows"
$guid       = [guid]::newguid();
$sizeBytes  = $(10 * (1024 * 1024 * 1024))
#'------------------------------------------------------------------------------
#'Set the LUN attributes to create and convert it JSON.
#'------------------------------------------------------------------------------
$lun = @{}
$lun.Add("storage_vm_key", $vserverKey)
$lun.Add("is_online", $True)
$lun.Add("is_space_alloc_enabled", $False)
$lun.Add("is_space_reservation_enabled", $False)
$lun.Add("volume_key", $volumeKey)
$lun.Add("multi_protocol_type", $lunType)
$lun.Add("comment", $guid)
$lun.Add("size", $sizeBytes)
$body = $lun | ConvertTo-Json
#'------------------------------------------------------------------------------
#'Create the LUN.
#'------------------------------------------------------------------------------
Write-Host "Creating LUN"
Write-Host ""
Write-Host "Cluster`: $clusterKey"
Write-Host "Vserver`: $vserverKey"
Write-Host "Volume`: $volumeKey"
Write-Host
$body
Write-Host ""
$uri    = "https://$SlmIPAddress`:$PortNumber/api/2.0/ontap/luns?name=$lunName"
$result = Invoke-RestMethod -Method Post -Uri $uri -Body $body -Headers @{"content-type"="application/json"} -Credential $credentials
#'------------------------------------------------------------------------------&lt;/PRE&gt;&lt;P&gt;Example output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PS C:\Scripts\PowerShell\Projects\SLM\CreateLun&amp;gt; .\CreateLun.ps1 -ClusterName cluster1 -LunName "lun_008" -SlmIPAddress XX.XX.XX.XX
Creating LUN

Cluster: b3b81b41-62a5-11e7-95d3-005056ac3a25:type=cluster,uuid=b3b81b41-62a5-11e7-95d3-005056ac3a25
Vserver: b3b81b41-62a5-11e7-95d3-005056ac3a25:type=vserver,uuid=6cc0d8c9-62a6-11e7-95d3-005056ac3a25
Volume: b3b81b41-62a5-11e7-95d3-005056ac3a25:type=volume,uuid=8318434b-5485-4a8d-839d-8a76552c86bb

{
    "comment":  "be803746-1224-4c91-a868-319edd75ae79",
    "volume_key":  "b3b81b41-62a5-11e7-95d3-005056ac3a25:type=volume,uuid=8318434b-5485-4a8d-839d-8a76552c86bb",
    "storage_vm_key":  "b3b81b41-62a5-11e7-95d3-005056ac3a25:type=vserver,uuid=6cc0d8c9-62a6-11e7-95d3-005056ac3a25",
    "size":  10737418240,
    "is_online":  true,
    "is_space_reservation_enabled":  false,
    "is_space_alloc_enabled":  false,
    "multi_protocol_type":  "windows"
}&lt;/PRE&gt;&lt;P&gt;Example CLI output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;cluster1::&amp;gt; lun show
Vserver   Path                            State   Mapped   Type        Size
--------- ------------------------------- ------- -------- -------- --------
vserver3  /vol/iscsi_data_001/lun_001     online  unmapped windows   10.00GB
vserver3  /vol/iscsi_data_001/lun_002     online  unmapped windows   10.00GB
vserver3  /vol/iscsi_data_001/lun_003     online  unmapped windows   10.00GB
vserver3  /vol/iscsi_data_001/lun_004     online  unmapped windows   10.00GB
vserver3  /vol/iscsi_data_001/lun_005     online  unmapped windows   10.00GB
vserver3  /vol/iscsi_data_001/lun_006     online  unmapped windows   10.00GB
vserver3  /vol/iscsi_data_001/lun_007     online  unmapped windows   10.00GB
&lt;U&gt;&lt;STRONG&gt;vserver3  /vol/iscsi_data_001/lun_008     online  unmapped windows   10.00GB&lt;/STRONG&gt;&lt;/U&gt;
8 entries were displayed.&lt;/PRE&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Happy coding&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Matt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jun 2025 14:47:03 GMT</pubDate>
    <dc:creator>mbeattie</dc:creator>
    <dc:date>2025-06-04T14:47:03Z</dc:date>
    <item>
      <title>SLM - PowerShell</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/SLM-PowerShell/m-p/133193#M2440</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I recently installed SLM and found all the example code was in Perl\Python\Ruby. A good example can be found here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://netapp.io/2017/07/19/provision-storage-like-service-provider-netapp-service-level-manager/" target="_blank"&gt;http://netapp.io/2017/07/19/provision-storage-like-service-provider-netapp-service-level-manager/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Having that example code is great but it probably doesnt help all our windows customers out there...&lt;/P&gt;&lt;P&gt;So i thought it might be helpful to post a "very" basic example of using SLM to provision a LUN.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Whilst this example is targeting the creation of a LUN on cluster and vserver with ISCSI enabled (instead of targeting a cluster\storage service level) you get the idea (it's just an example to help you get started). One point worth noting is that i had to explicitly set TLS to version 1.1 to be able to connect to SLM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Param(
   [Parameter(Mandatory=$True, HelpMessage="The cluster name")]
   [String]$ClusterName,
   [Parameter(Mandatory=$True, HelpMessage="The lun name to create")]
   [String]$LunName,
   [Parameter(Mandatory=$True, HelpMessage="The IP Address of the SLM Server")]
   [String]$SlmIPAddress,
   [Parameter(Mandatory=$False, HelpMessage="The IP Address of the SLM Server")]
   [String]$PortNumber=8443
)
#'------------------------------------------------------------------------------
#'Ignore self signed SSL certificate on SLM server and set TLS version to 1.1
#'------------------------------------------------------------------------------
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;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls11
#'------------------------------------------------------------------------------
#'Prompt for Credentials to connect to SLM and enumerate the cluster.
#'------------------------------------------------------------------------------
$credentials = Get-Credential -Credential admin
$uri         = "https://$SlmIPAddress`:$PortNumber/api/2.0/ontap/clusters?name=$clusterName"
$result      = Invoke-RestMethod -Method Get -Uri $uri -Credential $credentials
$clusterKey  = $result.result.records.key
#'------------------------------------------------------------------------------
#'Enumerate the vserver.
#'------------------------------------------------------------------------------
$uri        = "https://$SlmIPAddress`:$PortNumber/api/2.0/ontap/storage-vms?cluster_key=$clusterKey&amp;amp;allowed_protocols=iscsi"
$result     = Invoke-RestMethod -Method Get -Uri $uri -Credential $credentials
$vserverKey = $result.result.records.key
#'------------------------------------------------------------------------------
#'Enumerate the vserver data volume.
#'------------------------------------------------------------------------------
$uri        = "https://$SlmIPAddress`:$PortNumber/api/2.0/ontap/volumes?storage_vm_key=$vserverKey&amp;amp;is_storage_vm_root=false"
$result     = Invoke-RestMethod -Method Get -Uri $uri -Credential $credentials
$volumeKey  = $result.result.records.key
$lunType    = "windows"
$guid       = [guid]::newguid();
$sizeBytes  = $(10 * (1024 * 1024 * 1024))
#'------------------------------------------------------------------------------
#'Set the LUN attributes to create and convert it JSON.
#'------------------------------------------------------------------------------
$lun = @{}
$lun.Add("storage_vm_key", $vserverKey)
$lun.Add("is_online", $True)
$lun.Add("is_space_alloc_enabled", $False)
$lun.Add("is_space_reservation_enabled", $False)
$lun.Add("volume_key", $volumeKey)
$lun.Add("multi_protocol_type", $lunType)
$lun.Add("comment", $guid)
$lun.Add("size", $sizeBytes)
$body = $lun | ConvertTo-Json
#'------------------------------------------------------------------------------
#'Create the LUN.
#'------------------------------------------------------------------------------
Write-Host "Creating LUN"
Write-Host ""
Write-Host "Cluster`: $clusterKey"
Write-Host "Vserver`: $vserverKey"
Write-Host "Volume`: $volumeKey"
Write-Host
$body
Write-Host ""
$uri    = "https://$SlmIPAddress`:$PortNumber/api/2.0/ontap/luns?name=$lunName"
$result = Invoke-RestMethod -Method Post -Uri $uri -Body $body -Headers @{"content-type"="application/json"} -Credential $credentials
#'------------------------------------------------------------------------------&lt;/PRE&gt;&lt;P&gt;Example output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PS C:\Scripts\PowerShell\Projects\SLM\CreateLun&amp;gt; .\CreateLun.ps1 -ClusterName cluster1 -LunName "lun_008" -SlmIPAddress XX.XX.XX.XX
Creating LUN

Cluster: b3b81b41-62a5-11e7-95d3-005056ac3a25:type=cluster,uuid=b3b81b41-62a5-11e7-95d3-005056ac3a25
Vserver: b3b81b41-62a5-11e7-95d3-005056ac3a25:type=vserver,uuid=6cc0d8c9-62a6-11e7-95d3-005056ac3a25
Volume: b3b81b41-62a5-11e7-95d3-005056ac3a25:type=volume,uuid=8318434b-5485-4a8d-839d-8a76552c86bb

{
    "comment":  "be803746-1224-4c91-a868-319edd75ae79",
    "volume_key":  "b3b81b41-62a5-11e7-95d3-005056ac3a25:type=volume,uuid=8318434b-5485-4a8d-839d-8a76552c86bb",
    "storage_vm_key":  "b3b81b41-62a5-11e7-95d3-005056ac3a25:type=vserver,uuid=6cc0d8c9-62a6-11e7-95d3-005056ac3a25",
    "size":  10737418240,
    "is_online":  true,
    "is_space_reservation_enabled":  false,
    "is_space_alloc_enabled":  false,
    "multi_protocol_type":  "windows"
}&lt;/PRE&gt;&lt;P&gt;Example CLI output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;cluster1::&amp;gt; lun show
Vserver   Path                            State   Mapped   Type        Size
--------- ------------------------------- ------- -------- -------- --------
vserver3  /vol/iscsi_data_001/lun_001     online  unmapped windows   10.00GB
vserver3  /vol/iscsi_data_001/lun_002     online  unmapped windows   10.00GB
vserver3  /vol/iscsi_data_001/lun_003     online  unmapped windows   10.00GB
vserver3  /vol/iscsi_data_001/lun_004     online  unmapped windows   10.00GB
vserver3  /vol/iscsi_data_001/lun_005     online  unmapped windows   10.00GB
vserver3  /vol/iscsi_data_001/lun_006     online  unmapped windows   10.00GB
vserver3  /vol/iscsi_data_001/lun_007     online  unmapped windows   10.00GB
&lt;U&gt;&lt;STRONG&gt;vserver3  /vol/iscsi_data_001/lun_008     online  unmapped windows   10.00GB&lt;/STRONG&gt;&lt;/U&gt;
8 entries were displayed.&lt;/PRE&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Happy coding&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Matt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 14:47:03 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/SLM-PowerShell/m-p/133193#M2440</guid>
      <dc:creator>mbeattie</dc:creator>
      <dc:date>2025-06-04T14:47:03Z</dc:date>
    </item>
  </channel>
</rss>

