-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathisilon_delete_share.ps1
27 lines (20 loc) · 1.13 KB
/
isilon_delete_share.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Accept input parameters
Param([String]$isilonip,[String]$username,[String]$password,[String]$sharename)
#if the correct parameters were not passed we exit after a message
if (!($isilonip -and $username -and $password -and $sharename)) {
write "failed to specify parameters";
write "Example: .\isilon_delete_shares_auth.ps1 -isilonip xxx.xxx.xxx.xxx -username root -password a -sharename data" ;
exit
}
$baseurl = "https://" + $isilonip + ":8080"
#create Jason Object to auth
$jobj = convertto-json (New-Object PSObject -Property @{username= $username;password = $password; services = ("platform","namespace")})
$resourceurl = "/session/1/session"
$uri = $baseurl + $resourceurl
#create session and save cookie in variable $session
$ISIObject = Invoke-RestMethod -Uri $uri -Body $jobj -ContentType "application/json; charset=utf-8" -Method POST -SessionVariable session
# Send call to Delete share
$resourceurl = "/platform/1/protocols/smb/shares/"
$uri = $baseurl + $resourceurl + $sharename
$uri
$ISIObject = Invoke-RestMethod -Uri $uri -WebSession $session -Method Delete -ContentType "application/json; charset=utf-8"