Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

Commit 8e65089

Browse files
authored
Develop (#77)
* Fix typo (#58) connexions => connections * Add classes and enums for Unity OE 4.5.1 * Bump to version 0.16.2 * Use basic parsing for Invoke-WebRequest. (#72) * feature: Add TreeQuota Management (#73) * feature: Add TreeQuota Management * Undefined param help on New-UnityTreeQuota.ps1 * (#1)
1 parent e302302 commit 8e65089

15 files changed

Lines changed: 4778 additions & 4057 deletions
2.56 MB
Binary file not shown.
688 KB
Binary file not shown.

Tools/Classes/Compare-Class.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#importing the module with the using statement, classes will be available in the session
22
using module '..\..\Unity-Powershell'
33

4+
[CmdletBinding()]
5+
Param ()
6+
47
Function Format-Type {
58
[CmdletBinding()]
69
Param (
@@ -35,8 +38,7 @@ $Module = Get-Module -Name 'Unity-Powershell'
3538

3639
# Get classes defined by the module
3740
$ActualClasses = $Module.ImplementingAssembly.DefinedTypes | where-Object IsPublic | Where-Object {$_.Name -notlike '*Enum'}
38-
39-
$Datas = @( Get-ChildItem -Path F:\Code\GitHub\Unity-Powershell\Tests\Class\Data\*.json -ErrorAction SilentlyContinue )
41+
$Datas = @( Get-ChildItem -Path C:\Users\erwan\Documents\Code\Unity-Powershell\Tests\Class\Data\*.json -ErrorAction SilentlyContinue )
4042

4143
Foreach($Data in $Datas) {
4244

212 KB
Binary file not shown.
Binary file not shown.

Unity-Powershell/Private/Send-UnityRequest.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function Send-UnityRequest {
1717
If (($Method -eq 'GET') -or ($type -eq 'DELETE')) {
1818
Try
1919
{
20-
$data = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Websession $Session.Websession -Headers $session.headers -Method $Method
20+
$data = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Websession $Session.Websession -Headers $session.headers -Method $Method -UseBasicParsing
2121
return $data
2222
}
2323
Catch
@@ -30,7 +30,7 @@ function Send-UnityRequest {
3030
Try
3131
{
3232
$json = $body | ConvertTo-Json -Depth 10
33-
$data = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Body $json -Websession $Session.Websession -Headers $session.headers -Method $Method -TimeoutSec 6000
33+
$data = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Body $json -Websession $Session.Websession -Headers $session.headers -Method $Method -TimeoutSec 6000 -UseBasicParsing
3434
return $data
3535
}
3636
Catch
@@ -44,9 +44,9 @@ function Send-UnityRequest {
4444
{
4545
If ($body) {
4646
$json = $body | ConvertTo-Json -Depth 10
47-
$data = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Body $json -Websession $Session.Websession -Headers $session.headers -Method $Method
47+
$data = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Body $json -Websession $Session.Websession -Headers $session.headers -Method $Method -UseBasicParsing
4848
} else {
49-
$data = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Websession $Session.Websession -Headers $session.headers -Method $Method
49+
$data = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Websession $Session.Websession -Headers $session.headers -Method $Method -UseBasicParsing
5050
}
5151
return $data
5252
}

Unity-Powershell/Private/Test-UnityConnection.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Function Test-UnityConnection {
1818
Write-Verbose "URI: $URI"
1919

2020
Try {
21-
$request = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Websession $sess.Websession -Headers $sess.headers -Method 'GET'
21+
$request = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Websession $sess.Websession -Headers $sess.headers -Method 'GET' -UseBasicParsing
2222
}
2323

2424
Catch {

Unity-Powershell/Private/Unblock-UnityCerts.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Function Unblock-UnityCerts {
22

3-
# Hack for allowing untrusted SSL certs with https connexions
3+
# Hack for allowing untrusted SSL certs with https connections
44
Add-Type -TypeDefinition @"
55
using System.Net;
66
using System.Security.Cryptography.X509Certificates;

Unity-Powershell/Public/Disconnect-Unity.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Function Disconnect-Unity {
5555
if ($pscmdlet.ShouldProcess($sess.Server,"Disconnecting from Unity Array")) {
5656

5757
#Sending request
58-
$request = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Websession $sess.Websession -Headers $sess.headers -Method POST
58+
$request = Invoke-WebRequest -Uri $URI -ContentType "application/json" -Websession $sess.Websession -Headers $sess.headers -Method POST -UseBasicParsing
5959

6060
If ($request.StatusCode -eq 200) {
6161
Write-Verbose "Delete session from DefaultUnitySession"
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Function Get-UnityTreeQuota {
2+
3+
<#
4+
.SYNOPSIS
5+
Queries the EMC Unity array to retrieve informations about treequotas.
6+
.DESCRIPTION
7+
Querries the EMC Unity array to retrieve informations about treequotas.
8+
You need to have an active session with the array.
9+
.NOTES
10+
Written by Albert Hugas under MIT licence - https://github.com/equelin/Unity-Powershell/blob/master/LICENSE
11+
.LINK
12+
https://github.com/equelin/Unity-Powershell
13+
.PARAMETER Session
14+
Specifies an UnitySession Object.
15+
.PARAMETER Path
16+
Specifies the treeQuota Path of the TreeQuota to return.
17+
.PARAMETER ID
18+
Specifies the TreeQuota ID.
19+
.PARAMETER Filesystem
20+
Specifies the filesystem where is the TreeQuota
21+
.PARAMETER State
22+
Specifies the TreeQuota states: 0=Ok, 3=xxx
23+
.EXAMPLE
24+
Get-UnityTreeQuota
25+
26+
Retrieve information about treequota
27+
.EXAMPLE
28+
Get-UnityTreeQuota -ID 'treequota_123456_12'
29+
30+
Retrieves information about treequota id treequota_123456_12
31+
.EXAMPLE
32+
$fs = Get-UnityFilesystem -Name 'TEST_FS'
33+
Get-UnityTreeQuota -filesystem $fs.Id
34+
35+
Retrieves information about all treequota in filesystem 'TEST_FS'
36+
#>
37+
38+
[CmdletBinding(DefaultParameterSetName="Filter")]
39+
Param (
40+
[Parameter(Mandatory = $false,HelpMessage = 'EMC Unity Session')]
41+
$session = ($global:DefaultUnitySession | where-object {$_.IsConnected -eq $true}),
42+
[Parameter(Mandatory = $false,ParameterSetName="Path",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'Path Name')]
43+
[String[]]$Path,
44+
[Parameter(Mandatory = $false,ParameterSetName="ID",ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,HelpMessage = 'TreeQuota ID')]
45+
[String[]]$ID,
46+
[Parameter(Mandatory = $false,ParameterSetName="Filter",HelpMessage = 'Filesystem')]
47+
[String[]]$Filesystem,
48+
[Parameter(Mandatory = $false,ParameterSetName="Filter",HelpMessage = 'TreeQuota State')]
49+
[String[]]$State
50+
51+
)
52+
53+
Begin {
54+
Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
55+
56+
#Initialazing variables
57+
$URI = '/api/types/treeQuota/instances' #URI
58+
$Typename = "UnitytreeQuota"
59+
$Filter = ""
60+
}
61+
62+
Process {
63+
Foreach ($sess in $session) {
64+
65+
Write-Debug -Message "[$($MyInvocation.MyCommand)] Processing Session: $($Session.Server) with SessionId: $($Session.SessionId)"
66+
67+
# Process parameters to create search filter
68+
if ( $ID ) {
69+
$Filter = "id eq `"$ID`""
70+
} elseif ( $Path ) {
71+
$Filter = "path eq `"$Path`""
72+
}
73+
74+
if ( $Filesystem ) {
75+
if ( $Filter ){ $Filter += " and " }
76+
$Filter += "filesystem eq `"$Filesystem`""
77+
}
78+
79+
if ( $State ) {
80+
if ( $Filter ){ $Filter += " and " }
81+
$Filter += "state eq `"$State`""
82+
}
83+
84+
Get-UnityItemByKey -Session $Sess -URI $URI -Typename $Typename -Key "ID" -Filter $Filter
85+
86+
} # End Foreach ($sess in $session)
87+
} # End Process
88+
} # End Function

0 commit comments

Comments
 (0)