This post is more than 5 years old
1 Rookie
•
9 Posts
0
4865
June 6th, 2013 11:00
Creating a CIFS Share using Powershell
Has anyone had any experience connecting to their Isilon and creating a CIFS share using powershell?
I am curious as to what your steps were, and how you did it.
thanks.
No Events found!



JeremyS
17 Posts
1
September 30th, 2013 10:00
Hi Brian, check out my two blog posts here --> https://community.emc.com/community/connect/isilon/blog/2013/09/25/using-powershell-with-the-papi-and-ran--the-basics to get all the info you'll need to get started with Powershell and the API. I'm also going to post below here the code you would need to create a share. If for some reason the formatting makes it difficult, just email me directly and I'll send you the .ps1 file.
Thanks!
######################################################################################################################################################
#
# Created: 09/30/2013 by Jeremy Smith, EMC NAS Specialist Central Division
# Modified:
#
#
# ps_isilon_create_share_via_papi.ps1 - create a share
# Note: You need to be at OneFS 7 or greater to leverage the PAPI and HTTP Access must be enabled on the cluster.
#
# PARAMETERS
#
# -isilonip = node IP
# -username
# -password
# -path = /ifs directory path for share
# -name = share name
#
#
# EXAMPLE
# .\ps_isilon_create_share_via_papi.ps1 -isilonip 10.10.10.1 -user root -password a -path /ifs/data/test -name "test$"
#
#
########################################################################################################################################
# Accept input parameters
Param([String]$isilonip,[String]$username,[String]$password,[String]$path,[String]$name)
# With a default cert you would normally see a cert error (code from blogs.msdn.com)
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAll : ICertificatePolicy {
public TrustAll() {}
public bool CheckValidationResult(
ServicePoint sPoint, X509Certificate cert,
WebRequest req, int problem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = new-object TrustAll
#if the correct parameters were not passed we exit after a message
if (!($isilonip -and $username -and $password -and $path -and $name)) {
write "failed to specify parameters";
write "Example: .\ps_isilon_set_quotas_via_papi.ps1 -isilonip 192.168.1.2 -username root -password a -path /ifs/data/jeremy/test -name testshare";
exit
}
# Encode basic authorization header and create baseurl
$EncodedAuthorization = [System.Text.Encoding]::UTF8.GetBytes($username + ':' + $password)
$EncodedPassword = [System.Convert]::ToBase64String($EncodedAuthorization)
$headers = @{"Authorization"="Basic $($EncodedPassword)"}
$baseurl = 'https://' + $isilonip +":8080"
Write-Host " "
# Create share
$resource = "/platform/1/protocols/smb/shares"
Write-Host "Creating a share at $path called $name"
$ShareObject = @"
{"name":"$name", "path": "$path"}
"@
$headers = @{"Authorization"="Basic $($EncodedPassword)"}
$uri = $baseurl + $resource
$ISIObject2 = Invoke-RestMethod -Uri $uri -Headers $headers -Body $ShareObject -ContentType "application/json; charset=utf-8" -Method POST
$ISIObject2
Write-Host "`nDone!"
soetingr
1 Rookie
•
40 Posts
0
June 10th, 2013 12:00
I use python to do everything, but while searching i found David Muegge's blog. (David Muegge’s Blog)
He wrote some stuff about it. Hope it helps.