diff --git a/Active Directory/api_config-ActiveDirectory.psd1 b/Active Directory/api_config-ActiveDirectory.psd1 index b31897c..1ffb7e5 100644 --- a/Active Directory/api_config-ActiveDirectory.psd1 +++ b/Active Directory/api_config-ActiveDirectory.psd1 @@ -17,10 +17,10 @@ fields are present in that template. #> -# REQUIRED -org_id = "" -# REQUIRED -flexible_asset_type_id = "" + # REQUIRED + org_id = '' + # REQUIRED + flexible_asset_type_id = '105647' @@ -35,16 +35,16 @@ the README.md file for more information on how to fill this out. #> - key_name_ADForestName = "" - key_name_ADFunctionalLevel = "" - key_name_DomainName = "" - key_name_DomainShortName = "" - key_name_SchemaMaster = "" - key_name_DomainNamingMaster = "" - key_name_RIDMaster = "" - key_name_PDCEmulator = "" - key_name_InfrastructureMaster = "" - key_name_GlobalCatalogServers = "" + key_name_ADForestName = 'forest-name' + key_name_ADFunctionalLevel = 'ad-level' + key_name_DomainName = 'domain-full-name' + key_name_DomainShortName = 'domain-short-name' + key_name_SchemaMaster = 'schema-master' + key_name_DomainNamingMaster = 'domain-naming-master' + key_name_RIDMaster = 'relative-id-rid-master' + key_name_PDCEmulator = 'pdc-emulator-master' + key_name_InfrastructureMaster = 'infrastructure-master' + key_name_GlobalCatalogServers = 'global-catalog-servers-domain-controllers' } \ No newline at end of file diff --git a/File Shares/FileShares.ps1 b/File Shares/FileShares.ps1 index 41cca9d..fcdb312 100644 --- a/File Shares/FileShares.ps1 +++ b/File Shares/FileShares.ps1 @@ -1,26 +1,20 @@ <# .SYNOPSIS This script grabs all shared folders in the current server along with their shared path, disk path and permsissions - .DESCRIPTION Options: - -help - Display the current help menu -silent - Run the script without printing anything -api - Declare a file name for an API config file to post flex asset directly to IT Glue -file - Declare a location to save script output to as a csv -organization - Declare the name of the organization - .NOTES This script is largely a modification on grolo's "Audit File Share Perms" script available at http://poshcode.org/3398. We thank grolo for doing a lot of the heavy lifting for us. - Author: Mark Jacobs Author: Caleb Albers - .LINK https://github.com/itglue/automation - #> [cmdletbinding()] @@ -54,8 +48,8 @@ function writeOutput { Write-Host "Disk Path: `t" -ForegroundColor Gray -NoNewline Write-Host "`t `t" $DiskPath "`n" - <#Write-Host "Permissions: `t" -ForegroundColor Gray -NoNewline - Write-Host "`t `t" $permissions "`n"#> + Write-Host "Permissions: `t" -ForegroundColor Gray -NoNewline + Write-Host "`t `t" $permissions "`n" } function updateAPIConfigFile { @@ -167,10 +161,10 @@ else { $computer = $env:COMPUTERNAME $SaveData = @() - $Files = gwmi -Class win32_share -ComputerName $computer -Filter "Type=0" | Where-Object{$_.Name -NotMatch "^print|^NETLOGON|^MTATempStore|^prnproc"} - $shares = $Files| select -ExpandProperty Name - $description = $Files| select -ExpandProperty Description - $path = $Files| select -ExpandProperty Path + $Files = Get-WmiObject -Class win32_share -ComputerName $computer -Filter "Type=0" | Where-Object{$_.Name -NotMatch "^print|^NETLOGON|^MTATempStore|^prnproc"} + $shares = $Files| Select-Object -ExpandProperty Name + $description = $Files| Select-Object -ExpandProperty Description + $path = $Files| Select-Object -ExpandProperty Path $server= ([regex]::matches($Files, "(?<=[\\][\\])[^\\]+")) $i=0 @@ -238,13 +232,13 @@ else { $api__org_id = $api__body.data.attributes.organization_id $api__flex_asset_id = $api_config.flex_asset_id - if($api__org_id) { + #if($api__org_id) { Write-Host "Creating a new flexible asset." $api__output_data = New-ITGlueFlexibleAssets -data $api__body $api__output_data - } + #} } else { Write-Error "ERROR: File Shares flex asset configuration file was found. Please create one and re-run the script." diff --git a/File Shares/api_config-FileShares.psd1 b/File Shares/api_config-FileShares.psd1 index 4307484..cfb2742 100644 --- a/File Shares/api_config-FileShares.psd1 +++ b/File Shares/api_config-FileShares.psd1 @@ -1,11 +1,11 @@ @{ org_id = '' - flexible_asset_type_id = '' + flexible_asset_type_id = '105879' - key_name_ShareName = '' - key_name_ShareDescription = '' - key_name_Server = '' - key_name_SharePath = '' - key_name_DiskPath = '' - key_name_Permissions = '' + key_name_ShareName = 'share-name' + key_name_ShareDescription = 'share-description' + key_name_Server = 'servers' + key_name_SharePath = 'share-path' + key_name_DiskPath = 'disk-path' + key_name_Permissions = 'share-permissions' } \ No newline at end of file diff --git a/PSWrapperSetup.ps1 b/PSWrapperSetup.ps1 new file mode 100644 index 0000000..ba01f1e --- /dev/null +++ b/PSWrapperSetup.ps1 @@ -0,0 +1,71 @@ +<# + +.SYNOPSIS +This script installs and completes the initial setup of the ITGlue PowerShell Wrapper. + +.DESCRIPTION +Options: + + -APIKey - Your ITGlue API key + -RememberAPI - Exports a configuration file at %UserProfile%\ITGlueAPI which stores your base uri and API key + +.EXAMPLE +./PSWrapperSetup.ps1 -APIKey APIKeyHere +./PSWrapperSetup.ps1 -APIKey APIKeyHere -RememberAPI + +.NOTES +Author: Shay Hosking + +For more information on the ITGlue PowerShell wrapper go to https://github.com/itglue/powershellwrapper + +.LINK +https://github.com/DefaultDrop/DocAutomation + +#> + +Param( + + [switch]$RememberAPI = $false, + + [Parameter(Mandatory = $true)] + [string]$APIKey + +) + +# Checks if ITGlue PowerShell module is installed and installs if not +$ModuleName = "ITGlueAPI" + +if (Get-Module -ListAvailable -Name $ModuleName) { + Write-Host "$ModuleName installed OK" -ForegroundColor Green +} +else { + Write-Host "$ModuleName not installed" -ForegroundColor Yellow + Write-Host "Installing..." -ForegroundColor Yellow + try { + # Set PowerShell Gallery to trusted + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + # Install module with current user to avoid running as admin + Install-Module -Name $ModuleName -Scope CurrentUser -ErrorAction Stop + } + catch { + #If the install fails, write the message to the screen + $ErrorMessage = $_.Exception.Message + Write-Host "Failed to install $ModuleName" -ForegroundColor Red + Write-Host $ErrorMessage -ForegroundColor Red + } +} + +# Configure ITGlue base URI, using the default api.itglue.com URI +Write-Host "Adding base URI" +Add-ITGlueBaseURI + +# Configure ITGlue API key +Write-Host "Adding API key" +Add-ITGlueAPIKey -Api_Key $APIKey + +# If RememberAPI is specified then export the settings to a config file +if ($RememberAPI) { + Write-Host "Exporting module settings" + Export-ITGlueModuleSettings +} +