save-path.ps1
|
param ( # Path [Parameter()] [String] $Path, # Not prompt save [Parameter()] [switch] $List ) $currentpath = [Environment]::GetEnvironmentVariable('Path', 1) -split ";" if ($Path -ne "") { $currentpath = $currentpath | Where-Object { $_ -Match $Path } } $currentpath if (!$List -and $Path -eq "") { Add-Type -AssemblyName System.Windows.Forms $SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog $SaveFileDialog.initialDirectory = "$HOME\Downloads" $SaveFileDialog.filename = "user-path" $SaveFileDialog.title = "Save as" $SaveFileDialog.filter = "Plain text|*.txt|All Files|*.*" $result = $SaveFileDialog.ShowDialog() if ($result -eq "OK") { $currentpath | Out-File $SaveFileDialog.filename -Force } } <#PSScriptInfo .VERSION 1.0 .GUID 9c23f3cd-ab99-4655-b997-0989e9d7753e .AUTHOR Belloah .COMPANYNAME .COPYRIGHT .TAGS .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES .PRIVATEDATA #> <# .DESCRIPTION Save user PATH environment variable to a text file #> |