mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 13:04:59 +02:00
75 lines
1.9 KiB
Markdown
75 lines
1.9 KiB
Markdown
Script: *install-edit.ps1*
|
|
========================
|
|
|
|
This PowerShell script installs Microsoft Edit.
|
|
|
|
Parameters
|
|
----------
|
|
```powershell
|
|
PS> ./install-edit.ps1 [<CommonParameters>]
|
|
|
|
[<CommonParameters>]
|
|
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
|
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
|
```
|
|
|
|
Example
|
|
-------
|
|
```powershell
|
|
PS> ./install-edit.ps1
|
|
⏳ Installing Microsoft Edit from Microsoft Store...
|
|
✅ Microsoft Edit installed successfully (took 25s).
|
|
|
|
```
|
|
|
|
Notes
|
|
-----
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
Related Links
|
|
-------------
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
Script Content
|
|
--------------
|
|
```powershell
|
|
<#
|
|
.SYNOPSIS
|
|
Installs Edit
|
|
.DESCRIPTION
|
|
This PowerShell script installs Microsoft Edit.
|
|
.EXAMPLE
|
|
PS> ./install-edit.ps1
|
|
⏳ Installing Microsoft Edit from Microsoft Store...
|
|
✅ Microsoft Edit installed successfully (took 25s).
|
|
.LINK
|
|
https://github.com/fleschutz/PowerShell
|
|
.NOTES
|
|
Author: Markus Fleschutz | License: CC0
|
|
#>
|
|
|
|
#requires -version 5.1
|
|
|
|
try {
|
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
|
|
|
if ($IsLinux) {
|
|
"⏳ Installing Microsoft Edit from Snap Store..."
|
|
& sudo snap install msedit
|
|
if ($lastExitCode -ne 0) { throw "Can't install Microsoft Edit, is it already installed?" }
|
|
} else {
|
|
"⏳ Installing Microsoft Edit from Microsoft Store..."
|
|
& winget install --id Microsoft.Edit --accept-package-agreements --accept-source-agreements
|
|
if ($lastExitCode -ne 0) { throw "Can't install Microsoft Edit, is it already installed?" }
|
|
}
|
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
|
"✅ Microsoft Edit installed successfully (took $($elapsed)s)."
|
|
exit 0 # success
|
|
} catch {
|
|
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
|
exit 1
|
|
}
|
|
```
|
|
|
|
*(page generated by convert-ps2md.ps1 as of 08/07/2025 16:01:04)*
|