mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-12 06:02:56 +02:00
Updated the cd-*.ps1 scripts
This commit is contained in:
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$path = Resolve-Path "~/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup"
|
$path = Resolve-Path "~/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup"
|
||||||
if (-not(Test-Path "$path" -pathType container)) {
|
if (-not(Test-Path "$path" -pathType container)) {
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) { throw "Sorry, Windows only" }
|
if ($IsLinux) { throw "Sorry, Windows only" }
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux -or $IsMacOS) {
|
if ($IsLinux -or $IsMacOS) {
|
||||||
if (-not(Test-Path "~/Desktop" -pathType container)) {
|
if (-not(Test-Path "~/Desktop" -pathType container)) {
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (-not(Test-Path "~/Dropbox" -pathType container)) {
|
if (-not(Test-Path "~/Dropbox" -pathType container)) {
|
||||||
throw "No 'Dropbox' folder in your home directory - is Dropbox installed?"
|
throw "No 'Dropbox' folder in your home directory - is Dropbox installed?"
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux -or $IsMacOS) {
|
if ($IsLinux -or $IsMacOS) {
|
||||||
$path = "/etc"
|
$path = "/etc"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the Jenkins home directory.
|
This PowerShell script changes the working directory to the Jenkins home directory.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-jenkins
|
PS> ./cd-jenkins.ps1
|
||||||
📂C:\Users\Markus\.jenkins entered (has 2 files and 21 folders)
|
📂C:\Users\Markus\.jenkins entered (has 2 files and 21 folders)
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Test-Path "~/.jenkins" -pathType container) {
|
if (Test-Path "~/.jenkins" -pathType container) {
|
||||||
$path = "~/.jenkins"
|
$path = "~/.jenkins"
|
||||||
|
@ -4,14 +4,16 @@
|
|||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the current working directory to the logs directory.
|
This PowerShell script changes the current working directory to the logs directory.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-logs
|
PS> ./cd-logs.ps1
|
||||||
📂/var/logs entered (has 3 files and 2 subfolders)
|
📂/var/logs with 3 files and 2 folders entered.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
function GetLogsDir {
|
function GetLogsDir {
|
||||||
if ($IsLinux -or $IsMacOS) { return "/var/logs" }
|
if ($IsLinux -or $IsMacOS) { return "/var/logs" }
|
||||||
$WinDir = [System.Environment]::GetFolderPath('Windows')
|
$WinDir = [System.Environment]::GetFolderPath('Windows')
|
||||||
@ -23,9 +25,9 @@ try {
|
|||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
$files = Get-ChildItem $path -attributes !Directory
|
$files = Get-ChildItem $path -attributes !Directory
|
||||||
$folders = Get-ChildItem $path -attributes Directory
|
$folders = Get-ChildItem $path -attributes Directory
|
||||||
"📂$path entered (has $($files.Count) files and $($folders.Count) subfolders)"
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
if (-not(Test-Path "~/Music/" -pathType container)) {
|
if (-not(Test-Path "~/Music/" -pathType container)) {
|
||||||
@ -30,6 +32,6 @@ try {
|
|||||||
"📂$path with $($folders.Count) folders and $($files.Count) files entered."
|
"📂$path with $($folders.Count) folders and $($files.Count) files entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,16 @@
|
|||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the user's NextCloud folder.
|
This PowerShell script changes the working directory to the user's NextCloud folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-nextcloud
|
PS> ./cd-nextcloud.ps1
|
||||||
📂C:\Users\Markus\NextCloud entered (has 2 files and 0 folders)
|
📂C:\Users\Markus\NextCloud with 2 files and 0 folders entered.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (-not(Test-Path "~/NextCloud" -pathType container)) {
|
if (-not(Test-Path "~/NextCloud" -pathType container)) {
|
||||||
throw "No 'NextCloud' folder in your home directory - is NextCloud installed?"
|
throw "No 'NextCloud' folder in your home directory - is NextCloud installed?"
|
||||||
@ -20,9 +22,9 @@ try {
|
|||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
$files = Get-ChildItem $path -attributes !Directory
|
$files = Get-ChildItem $path -attributes !Directory
|
||||||
$folders = Get-ChildItem $path -attributes Directory
|
$folders = Get-ChildItem $path -attributes Directory
|
||||||
"📂$path entered (has $($files.Count) files and $($folders.Count) folders)"
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (-not(Test-Path "~/OneDrive" -pathType container)) {
|
if (-not(Test-Path "~/OneDrive" -pathType container)) {
|
||||||
throw "No 'OneDrive' folder in your home directory - is OneDrive installed?"
|
throw "No 'OneDrive' folder in your home directory - is OneDrive installed?"
|
||||||
@ -23,6 +25,6 @@ try {
|
|||||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working dir to the user's pictures folder
|
Sets the working dir to the user's pictures folder
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script sets the current working directory to the user's pictures folder.
|
This PowerShell script changes the current working directory to the user's pictures folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-pics.ps1
|
PS> ./cd-pics.ps1
|
||||||
📂C:\Users\Markus\Pictures with 7 files and 0 folders entered.
|
📂C:\Users\Markus\Pictures with 7 files and 0 folders entered.
|
||||||
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
if (-not(Test-Path "~/Pictures" -pathType container)) {
|
if (-not(Test-Path "~/Pictures" -pathType container)) {
|
||||||
@ -30,6 +32,6 @@ try {
|
|||||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working dir to the Public folder
|
Sets the working dir to the Public folder
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script sets the current working directory to the Public folder.
|
This PowerShell script changes the current working directory to the Public folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-public.ps1
|
PS> ./cd-public.ps1
|
||||||
📂C:\Users\Public with 2 files and 3 folders entered.
|
📂C:\Users\Public with 2 files and 3 folders entered.
|
||||||
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
if (-not(Test-Path "~/Public" -pathType container)) {
|
if (-not(Test-Path "~/Public" -pathType container)) {
|
||||||
@ -30,6 +32,6 @@ try {
|
|||||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -2,27 +2,28 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to the 'recent' folder
|
Sets the working directory to the 'recent' folder
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the 'recent' folder.
|
This PowerShell script changes the current working directory to the 'recent' folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-recent
|
PS> ./cd-recent.ps1
|
||||||
📂C:\Users\Markus\AppData\Roaming\Microsoft\Windows\Recent entered (has 2 files and 3 subfolders)
|
📂C:\Users\Markus\AppData\Roaming\Microsoft\Windows\Recent with 2 files and 3 folders entered.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$path = [Environment]::GetFolderPath('Recent')
|
$path = [Environment]::GetFolderPath('Recent')
|
||||||
if (-not(Test-Path "$path" -pathType container)) {
|
if (-not(Test-Path "$path" -pathType container)) { throw "No recent folder at $path" }
|
||||||
throw "No recent folder at $path"
|
|
||||||
}
|
|
||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
$files = Get-ChildItem $path -attributes !Directory
|
$files = Get-ChildItem $path -attributes !Directory
|
||||||
$folders = Get-ChildItem $path -attributes Directory
|
$folders = Get-ChildItem $path -attributes Directory
|
||||||
"📂$path entered (has $($files.Count) files and $($folders.Count) subfolders)"
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working dir to the recycle bin folder
|
Sets the working dir to the recycle bin folder
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the user's recycle bin folder.
|
This PowerShell script changes the current working directory to the user's recycle bin folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-recycle-bin.ps1
|
PS> ./cd-recycle-bin.ps1
|
||||||
📂C:\$Recycle.Bin\S-1-5-21-123404-23309-294260-1001 with 2 files and 0 folders entered.
|
📂C:\$Recycle.Bin\S-1-5-21-123404-23309-294260-1001 with 2 files and 0 folders entered.
|
||||||
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
function GetCurrentUserSID { [CmdletBinding()] param()
|
function GetCurrentUserSID { [CmdletBinding()] param()
|
||||||
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
|
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
|
||||||
return ([System.DirectoryServices.AccountManagement.UserPrincipal]::Current).SID.Value
|
return ([System.DirectoryServices.AccountManagement.UserPrincipal]::Current).SID.Value
|
||||||
@ -33,6 +35,6 @@ try {
|
|||||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to a repo
|
Sets the working directory to a repo
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the given local Git repository.
|
This PowerShell script changes the current working directory to the given local Git repository.
|
||||||
.PARAMETER folderName
|
.PARAMETER folderName
|
||||||
Specifies the folder name of the Git repository
|
Specifies the folder name of the Git repository
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
@ -43,6 +43,6 @@ try {
|
|||||||
& git status --branch --short
|
& git status --branch --short
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working dir to the repos folder
|
Sets the working dir to the repos folder
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the folder for Git repositories.
|
This PowerShell script changes the current working directory to the folder for Git repositories.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-repos.ps1
|
PS> ./cd-repos.ps1
|
||||||
📂C:\Repos with 33 folders entered.
|
📂C:\Repos with 33 folders entered.
|
||||||
@ -32,6 +32,6 @@ try {
|
|||||||
"📂$path with $($folders.Count) folders entered."
|
"📂$path with $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux -or $IsMacOS) { $path = "/" } else { $path = "C:\" }
|
if ($IsLinux -or $IsMacOS) { $path = "/" } else { $path = "C:\" }
|
||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
@ -20,6 +22,6 @@ try {
|
|||||||
"📂$path with $($folders.Count) folders and $($files.Count) files entered."
|
"📂$path with $($folders.Count) folders and $($files.Count) files entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
function GetScreenshotsFolder {
|
function GetScreenshotsFolder {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
if (-not(Test-Path "~/Pictures" -pathType container)) { throw "No 'Pictures' folder in your home directory yet" }
|
if (-not(Test-Path "~/Pictures" -pathType container)) { throw "No 'Pictures' folder in your home directory yet" }
|
||||||
@ -33,6 +35,6 @@ try {
|
|||||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to the PowerShell scripts folder
|
Sets the working directory to the PowerShell scripts folder
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the PowerShell scripts folder.
|
This PowerShell script changes the currrent working directory to the PowerShell scripts folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-scripts.ps1
|
PS> ./cd-scripts.ps1
|
||||||
📂C:\Repos\PowerShell\scripts with 655 scripts entered.
|
📂C:\Repos\PowerShell\scripts with 655 scripts entered.
|
||||||
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$path = Resolve-Path "$PSScriptRoot"
|
$path = Resolve-Path "$PSScriptRoot"
|
||||||
if (-not(Test-Path "$path" -pathType container)) { throw "No scripts folder at: $path" }
|
if (-not(Test-Path "$path" -pathType container)) { throw "No scripts folder at: $path" }
|
||||||
@ -20,6 +22,6 @@ try {
|
|||||||
"📂$path with $($files.Count) scripts entered."
|
"📂$path with $($files.Count) scripts entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,12 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$path = "~/.ssh"
|
$path = "~/.ssh"
|
||||||
if (-not(Test-Path "$path" -pathType container)) {
|
if (-not(Test-Path "$path" -pathType container)) {
|
||||||
throw "Your home directory has no '.ssh' folder yet - Please install SSH."
|
throw "No '.ssh' folder in your home directory yet - Please install SSH."
|
||||||
}
|
}
|
||||||
$path = Resolve-Path "$path"
|
$path = Resolve-Path "$path"
|
||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
|
@ -12,9 +12,11 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (-not(Test-Path "~/Sync" -pathType container)) {
|
if (-not(Test-Path "~/Sync" -pathType container)) {
|
||||||
throw "Your home directory has no 'Sync' folder yet - Please install Syncthing."
|
throw "No 'Sync' folder in your home directory yet - Please install Syncthing."
|
||||||
}
|
}
|
||||||
$path = Resolve-Path "~/Sync"
|
$path = Resolve-Path "~/Sync"
|
||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
function GetTempDir {
|
function GetTempDir {
|
||||||
if ("$env:TEMP" -ne "") { return "$env:TEMP" }
|
if ("$env:TEMP" -ne "") { return "$env:TEMP" }
|
||||||
if ("$env:TMP" -ne "") { return "$env:TMP" }
|
if ("$env:TMP" -ne "") { return "$env:TMP" }
|
||||||
@ -21,9 +23,7 @@ function GetTempDir {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$path = GetTempDir
|
$path = GetTempDir
|
||||||
if (-not(Test-Path "$path" -pathType container)) { throw
|
if (-not(Test-Path "$path" -pathType container)) { throw "No temporary folder at: $path" }
|
||||||
"No temporary folder at: $path"
|
|
||||||
}
|
|
||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
$files = Get-ChildItem $path -attributes !Directory
|
$files = Get-ChildItem $path -attributes !Directory
|
||||||
$folders = Get-ChildItem $path -attributes Directory
|
$folders = Get-ChildItem $path -attributes Directory
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
if (-not(Test-Path "~/Templates" -pathType container)) {
|
if (-not(Test-Path "~/Templates" -pathType container)) {
|
||||||
@ -30,6 +32,6 @@ try {
|
|||||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working dir to the trash folder
|
Sets the working dir to the trash folder
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the user's trash folder.
|
This PowerShell script changes the current working directory to the user's trash folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-trash
|
PS> ./cd-trash.ps1
|
||||||
📂C:\$Recycle.Bin\S-1-5-21-123404-23309-294260-1001 with 4 files and 0 folders entered.
|
📂C:\$Recycle.Bin\S-1-5-21-123404-23309-294260-1001 with 4 files and 0 folders entered.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -35,6 +35,6 @@ try {
|
|||||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to one level up
|
Sets the working directory to one level up
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to one directory level up.
|
This PowerShell script changes the current working directory to one directory level up.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> .\cd-up
|
PS> .\cd-up.ps1
|
||||||
📂C:\Users
|
📂C:\Users
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$path = Resolve-Path ".."
|
$path = Resolve-Path ".."
|
||||||
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
||||||
@ -19,6 +21,6 @@ try {
|
|||||||
"📂$path"
|
"📂$path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to two directory levels up
|
Sets the working directory 2 directory levels up
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to two directory level up.
|
This PowerShell script changes the current working directory to two directory level up.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-up2
|
PS> ./cd-up2.ps1
|
||||||
📂C:\
|
📂C:\
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$path = Resolve-Path "../.."
|
$path = Resolve-Path "../.."
|
||||||
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
||||||
@ -19,6 +21,6 @@ try {
|
|||||||
"📂$path"
|
"📂$path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to three directory levels up
|
Sets the working directory 3 directory levels up
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to three directory levels up.
|
This PowerShell script changes the current working directory to three directory levels up.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-up3
|
PS> ./cd-up3.ps1
|
||||||
📂C:\
|
📂C:\
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$path = Resolve-Path "../../.."
|
$path = Resolve-Path "../../.."
|
||||||
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
||||||
@ -19,6 +21,6 @@ try {
|
|||||||
"📂$path"
|
"📂$path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to four directory levels up
|
Sets the working directory 4 directory levels up
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to four directory levels up.
|
This PowerShell script changes the current working directory to four directory levels up.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-up4
|
PS> ./cd-up4.ps1
|
||||||
📂C:\
|
📂C:\
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -12,6 +12,8 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$path = Resolve-Path "../../../.."
|
$path = Resolve-Path "../../../.."
|
||||||
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
||||||
@ -19,6 +21,6 @@ try {
|
|||||||
"📂$path"
|
"📂$path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -12,16 +12,17 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$path = Resolve-Path "~/.."
|
$path = Resolve-Path "~/.."
|
||||||
if (-not(Test-Path "$path" -pathType container)) {
|
if (-not(Test-Path "$path" -pathType container)) { throw "No users directory at: $path" }
|
||||||
throw "No users directory at: $path"
|
|
||||||
}
|
|
||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
$folders = Get-ChildItem $path -attributes Directory
|
$folders = Get-ChildItem $path -attributes Directory
|
||||||
"📂$path with $($folders.Count) folders entered."
|
"📂$path with $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,16 @@
|
|||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the user's videos folder.
|
This PowerShell script changes the working directory to the user's videos folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-videos
|
PS> ./cd-videos.ps1
|
||||||
📂C:\Users\Markus\Videos entered (has 3 files and 0 subfolders)
|
📂C:\Users\Markus\Videos with 3 files and 0 folders entered.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
#requires -version 5.1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
$path = Resolve-Path "~/Videos"
|
$path = Resolve-Path "~/Videos"
|
||||||
@ -24,9 +26,9 @@ try {
|
|||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
$files = Get-ChildItem $path -attributes !Directory
|
$files = Get-ChildItem $path -attributes !Directory
|
||||||
$folders = Get-ChildItem $path -attributes Directory
|
$folders = Get-ChildItem $path -attributes Directory
|
||||||
"📂$path entered (has $($files.Count) files and $($folders.Count) subfolders)"
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ ERROR: $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user