温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何用PowerShell连接微软云

发布时间:2020-06-18 15:35:29 来源:网络 阅读:556 作者:raincity 栏目:系统运维

最近有个需求要用Powershell要看迁移任务状态,原因就是微软O365网页看状态那个地方不准确的,你刚建立的任务,十分钟没有就说同步完成了。
所以要查看状态就必须用PowerShell.
我有一个脚本,但是执行时总出错,翻译成中文就是脚本执行Policy不许可。
第一步:于是我第一步用了一个命令:
PS C:\WINDOWS\system32> Get-ExecutionPolicy -list

    Scope ExecutionPolicy
    ----- ---------------

MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine RemoteSigned

第二步: 然后我就在想,我要去微软的云去验证,这个属性应该是RemoteSigned.当时不是这样的,于是我就写了一条命令如下:

PS C:\WINDOWS\system32> Get-ExecutionPolicy -list

    Scope ExecutionPolicy
    ----- ---------------

MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine RemoteSigned

PS C:\WINDOWS\system32> Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
PS C:\WINDOWS\system32>

第三步,其实还是不可以,然后我就找到另一个命令

Unlblock-File -path "CloudServicesShell.ps1" 想法就是把这个脚本的执行权限去掉。然后神奇的就解决了,脚本就可以执行了。

大家肯定想知道那个脚本代码是什么吧,因为有我们公司的信息,所以不方便外传,实在想要的,留言吧。

如何用PowerShell连接微软云

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI