飘在云端

东西南北,海角天涯

· 备查 · · 217次浏览

AWSPowerShell win7 x64 上本地安装和配置

环境:
win7 x64 Sp1 旗舰版
Powershell v5.1.14409.1005 (wwindows7 默认内置版本是 v2.0,我这里主动升级过了,升级补丁:Windows PowerShell v5.1(Win7支持的最高版本): https://www.alipan.com/s/8KdbZ8H6ztw,提取码 cw52

可以在PS输入 $psversiontable 检查PS版本

可以自行升级 PowerShell 版本或者使用默认预装 2.0 版本(如果你本地部署的话,在线安装对网速/PS 版本有要求)

特别提一下,高版本,如 PS v5.1 是可以使用在线安装的,但是微软官方源不知道有没有速度,也可以看看有没有国内的PS镜像源配置一下

或者干脆一点使用魔法, Clash Tun 模式的全局代理,加速下载
我这里自行下载最新模块本地安装部署

前置要求
PowerShell 的脚本执行策需要设置下,不然默认值 Restricted 是不允许任何脚本运行,只能运行命令

ps 输入 Set-ExecutionPolicy,提示要你输入参数, 策略的值需要为如下参数之一:RemoteSignedUnrestrictedBypass
我这里是 Bypass,允许任意脚本加载运行无需签名和检查
然后还有个坑,这个是分开算的
需要在 x64 的 PowerShell 执行设置一次
然后还要在 x86 的 PowerShell 也设置一次

  1. 下载本地离线的最新v4版本模块:
    https://sdk-for-net.amazonwebservices.com/ps/v4/latest/AWSPowerShell.zip
  2. 配置模块路径的环境变量
    因为 AWSPowerShell 模块包含了 ISE 模块,需要在 Windows PowerShell ISE 环境运行,与 Windows PowerShell 的配置文件有所区别,我们需要修改这个路径的文件
%userprofile%\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

默认情况下是没有这个文件 Microsoft.PowerShellISE_profile.ps1,新建一个这个文件名就行了,然后里面写一个本地模块导入命令

$env:PSModulePath += ";$env:userprofile\Desktop\4.1.508"

注意自行修改你的模块目录存放路径,我这里存到了桌面,支持使用 windows 内置环境变量,随后保存退出

  1. 导入模块,依次执行下面的4条命令
设置模块目录路径,模块zip压缩包路径,使用 userprofile Windows内置环境变量表示当前用户文件夹
$modulePath = "$env:userprofile\Desktop\4.1.508"
$zipFilePath = '$env:userprofile\Downloaded\AWSPowerShell.zip'
解压 AWSPowerShell.zip 文件到模块文件夹
Expand-Archive -Path $zipFilePath -DestinationPath $modulePath -Force
导入 AWSPowerShell 模块
Import-Module "$modulePath\AWSPowerShell.psd1"
  1. 检查 AWSPowerShell 模块是否可以加载

    Get-AWSPowerShellVersion

返回

AWS Tools for Windows PowerShell
Version 4.1.508
Copyright 2012-2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Amazon Web Services SDK for .NET
Core Runtime Version 3.7.302.6
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

Release notes: https://github.com/aws/aws-tools-for-powershell/blob/master/CHANGELOG.md

This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License
[http://logging.apache.org/log4net/license.html]

如果报错就是前面路径没有配置正确

最后就可以用了

评论 (0条)