scoop是一个类似于linux下apt之类包管理器
正常安装方法
iex (new-object net.webclient).downloadstring('https://get.scoop.sh') //默认安装目录:C:\Users\<user>\scoop
由于github下载访问有限,这里介绍使用离线方式
1.使用idm下载ps1文件,不行使用后面的代码,全部贴出
https://cdn.yulinyige.com/script/scoop-installs.ps1
2.修改ps1文件
从zipurl 地址下载相应的文件,放到copy-item 第一个路径下,实在下载不下来可使用这里
https://download.csdn.net/download/xinshuwei/85178429
添加copy两行copy item ,注释掉两行dl 下载命令
3.完整文件可使用下面的code
#Requires -Version 5
# remote install:
# Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
$old_erroractionpreference = $erroractionpreference
$erroractionpreference = 'stop' # quit if anything goes wrong
if (($PSVersionTable.PSVersion.Major) -lt 5) {
Write-Output "PowerShell 5 or later is required to run Scoop."
Write-Output "Upgrade PowerShell: https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell"
break
}
# show notification to change execution policy:
$allowedExecutionPolicy = @('Unrestricted', 'RemoteSigned', 'ByPass')
if ((Get-ExecutionPolicy).ToString() -notin $allowedExecutionPolicy) {
Write-Output "PowerShell requires an execution policy in [$($allowedExecutionPolicy -join ", ")] to run Scoop."
Write-Output "For example, to set the execution policy to 'RemoteSigned' please run :"
Write-Output "'Set-ExecutionPolicy RemoteSigned -scope CurrentUser'"
break
}
if ([System.Enum]::GetNames([System.Net.SecurityProtocolType]) -notcontains 'Tls12') {
Write-Output "Scoop requires at least .NET Framework 4.5"
Write-Output "Please download and install it first:"
Write-Output "https://www.microsoft.com/net/download"
break
}
# get core functions
$core_url = 'https://cdn.yulinyige.com/script/scoop-core.ps1'
Write-Output 'Initializing...'
Invoke-Expression (new-object net.webclient).downloadstring($core_url)
# prep
if (installed 'scoop') {
write-host "Scoop is already installed. Run 'scoop update' to get the latest version." -f red
# don't abort if invoked with iex that would close the PS session
if ($myinvocation.mycommand.commandtype -eq 'Script') { return } else { exit 1 }
}
$dir = ensure (versiondir 'scoop' 'current')
# download scoop zip
$zipurl = 'https://github.com/lukesampson/scoop/archive/master.zip'
$zipfile = "$dir\scoop.zip"
Write-Output 'Downloading scoop...'
copy-item C:\Users\lenovo\scoop\scoop.zip -Destination $dir\
#dl $zipurl $zipfile
Write-Output 'Extracting...'
Add-Type -Assembly "System.IO.Compression.FileSystem"
[IO.Compression.ZipFile]::ExtractToDirectory($zipfile, "$dir\_tmp")
Copy-Item "$dir\_tmp\*master\*" $dir -Recurse -Force
Remove-Item "$dir\_tmp", $zipfile -Recurse -Force
Write-Output 'Creating shim...'
shim "$dir\bin\scoop.ps1" $false
# download main bucket
$dir = "$scoopdir\buckets\main"
$zipurl = 'https://github.com/ScoopInstaller/Main/archive/master.zip'
$zipfile = "$dir\main-bucket.zip"
Write-Output 'Downloading main bucket...'
New-Item $dir -Type Directory -Force | Out-Null
copy-item C:\Users\lenovo\scoop\main-bucket.zip -Destination $dir\
#dl $zipurl $zipfile
Write-Output 'Extracting...'
[IO.Compression.ZipFile]::ExtractToDirectory($zipfile, "$dir\_tmp")
Copy-Item "$dir\_tmp\*-master\*" $dir -Recurse -Force
Remove-Item "$dir\_tmp", $zipfile -Recurse -Force
ensure_robocopy_in_path
ensure_scoop_in_path
scoop config lastupdate ([System.DateTime]::Now.ToString('o'))
success 'Scoop was installed successfully!'
Write-Output "Type 'scoop help' for instructions."
$erroractionpreference = $old_erroractionpreference # Reset $erroractionpreference to original value
4.自定义安装scoop目录
[environment]::setEnvironmentVariable('SCOOP','D:\Applications\Scoop','User') //第二个参数是自定义目录 $env:SCOOP='D:\Applications\Scoop' //和上一条命令的自定义目录相同 iex (new-object net.webclient).downloadstring('https://get.scoop.sh')//如果执行scoop命令报错-->set-executionpolicy remotesigned -scope currentuser
如何安装失败记得删除相应的文件夹
常用使用命令
scoop search package //搜索包 scoop install package //安装包 scoop cleanup package //移除旧版本的包 scoop bucket known //查看有哪几个butcket(仓库) scoop bucket list //查看已添加的butcket(仓库) scoop bucket add bucketName //添加bucket(仓库) scoop bucket rm bucketName //移除bucket(仓库)
这里参考这篇文档进行powershell 设置,成功上岸