commit c1c2b0e4e6a21c75946aba8ea13ba2c518c025c5 Author: Alexis Lazcano Date: Tue Dec 17 15:41:14 2024 -0600 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..012778b --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +*.TempPoint.* +*.Export.* +*.psproj +*.psprojs +*.RestorePoint.* +*.Run.ps1 +*.Package.ps1 +CustomMenu.inf +Test-*.ps1 +*.psbuild +bin/ \ No newline at end of file diff --git a/PSIsonas.psd1 b/PSIsonas.psd1 new file mode 100644 index 0000000..a358003 --- /dev/null +++ b/PSIsonas.psd1 @@ -0,0 +1,138 @@ +<# + =========================================================================== + Created with: SAPIEN Technologies, Inc., PowerShell Studio 2024 v5.8.251 + Created on: 12/17/2024 10:35 AM + Created by: Alexis Lazcano + Organization: Saratoga Corporate Management Group, LLC + Filename: PSIsonas.psd1 + ------------------------------------------------------------------------- + Module Manifest + ------------------------------------------------------------------------- + Module Name: PSIsonas + =========================================================================== +#> + + +@{ + + # Script module or binary module file associated with this manifest + RootModule = 'PSIsonas.psm1' + + # Version number of this module. + ModuleVersion = '1.0.0.0' + + # ID used to uniquely identify this module + GUID = '1fd60578-734d-4e9e-8c94-8f45bd4b92aa' + + # Author of this module + Author = 'Alexis Lazcano' + + # Company or vendor of this module + CompanyName = 'Saratoga Corporate Management Group, LLC' + + # Copyright statement for this module + Copyright = '(c) 2024. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'Powershell wrapper for Isonas Pure Access Cloud.' + + # Supported PSEditions + # CompatiblePSEditions = @('Core', 'Desktop') + + # Minimum version of the Windows PowerShell engine required by this module + PowerShellVersion = '5.1' + + # Name of the Windows PowerShell host required by this module + PowerShellHostName = '' + + # Minimum version of the Windows PowerShell host required by this module + PowerShellHostVersion = '' + + # Minimum version of the .NET Framework required by this module + DotNetFrameworkVersion = '4.5.2' + + # Minimum version of the common language runtime (CLR) required by this module + # CLRVersion = '' + + # Processor architecture (None, X86, Amd64, IA64) required by this module + ProcessorArchitecture = 'None' + + # Modules that must be imported into the global environment prior to importing + # this module + RequiredModules = @() + + # Assemblies that must be loaded prior to importing this module + RequiredAssemblies = @() + + # Script files (.ps1) that are run in the caller's environment prior to + # importing this module + ScriptsToProcess = @() + + # Type files (.ps1xml) to be loaded when importing this module + TypesToProcess = @() + + # Format files (.ps1xml) to be loaded when importing this module + FormatsToProcess = @() + + # Modules to import as nested modules of the module specified in + # ModuleToProcess + NestedModules = @() + + # Functions to export from this module + FunctionsToExport = @( + 'Get-IsonasRequestHeaders', + 'Test-IsonasConnection', + 'Get-IsonasUsers' + ) #For performance, list functions explicitly + + # Cmdlets to export from this module + CmdletsToExport = '*' + + # Variables to export from this module + VariablesToExport = '*' + + # Aliases to export from this module + AliasesToExport = '*' #For performance, list alias explicitly + + # DSC class resources to export from this module. + #DSCResourcesToExport = '' + + # List of all modules packaged with this module + ModuleList = @() + + # List of all files packaged with this module + FileList = @() + + # Private data to pass to the module specified in ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + + #Support for PowerShellGet galleries. + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + # LicenseUri = '' + + # A URL to the main website for this project. + # ProjectUri = '' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + } # End of PSData hashtable + + } # End of PrivateData hashtable +} + + + + + + + + diff --git a/PSIsonas.psm1 b/PSIsonas.psm1 new file mode 100644 index 0000000..8d49e48 --- /dev/null +++ b/PSIsonas.psm1 @@ -0,0 +1,82 @@ +<# + =========================================================================== + Created on: 12/17/2024 10:35 AM + Created by: Alexis Lazcano + Organization: Saratoga Corporate Management Group, LLC + Filename: PSIsonas.psm1 + ------------------------------------------------------------------------- + Module Name: PSIsonas + =========================================================================== +#> + +Function Get-IsonasRequestHeaders +{ + $tokenPair = "$env:ISONAS_TokenID`:$env:ISONAS_TokenValue" + $tokenBase64 = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($tokenPair)) + $Headers = @{ + 'Authorization' = "Basic $tokenBase64" + 'Content-Type' = 'application/merge-patch+json' + } + return $Headers +} + +function Test-IsonasConnection +{ + $API_Users = $env:ISONAS_API_URL + "users" + $Response = Invoke-RestMethod -Uri "$API_Users/?includeDisabled=false&limit=1" -Headers $(Get-IsonasRequestHeaders) + if ($Reponse.Status -eq "Success") { return $true } + else + { + return $false + } + +} + +function Get-IsonasUsers { + param + ( + [Parameter(Position = 1)] + [switch]$All, + [Parameter(Mandatory = $false, + Position = 2)] + [ValidateNotNullOrEmpty()] + [int]$Limit = 200, + [Parameter(Position = 3)] + [bool]$IncludeDisabled = $false + ) + $API_Users = $env:ISONAS_API_URL + "users" + + if ($All) + { + Write-Host "All users was used" + $TargetUrl = "$API_Users/" + } + else + { + Write-Host "All users was NOT used" + $TargetUrl = "$API_Users/?includeDisabled=$IncludeDisabled&limit=$Limit" + } + + $Response = Invoke-RestMethod -Uri $TargetUrl -Headers $(Get-IsonasRequestHeaders) -Method GET + + $flattened = $response | ForEach-Object { + $obj = [PSCustomObject]@{ + Id = $_.Id + CreatedTime = $_.createdTime + UpdatedTime = $_.updatedTime + FirstName = $_.firstName + LastName = $_.lastName + AreaID = $_.areaId + EmployeeId = $_.employeeId + IsDisabled = $_.isDisabled + } + foreach ($field in $_.userDefinedFields) + { + $propertyName = $field.name -replace '\s', '' + $obj | Add-Member -MemberType NoteProperty -Name $propertyName -Value $field.value + } + $obj + } + + return $flattened +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..16ce696 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# PSIsonas +--Overview high level of the program.-- +## Description +--Description of the program.-- +## Getting Started +--Information about getting the program setup.-- +## Help +--Additional information need to use the software.-- +## Authors +Alexis Lazcano +## Version History +2.1 +## License +--Software license information.-- +## Acknowledgments +--Place any acknowledgments here.--