Powershell core 在Linux上试用

本文发布时间: 2019-Mar-22
找了一个CentOS7的服务器,https://github.com/PowerShell/PowerShell/releases/ 这个上面下载对应的rpm文件,然后拷贝到我的/tmp目录,然后执行yum install的操作目前的版本还是alpha版本,所以肯定有很多bug,先尝尝鲜看看[root@sydnagios ~]# yum install /tmp/powershell-6.0.0_alpha.9-1.el7.centos.x86_64.rpmLoaded plugins: fastestmirror, langpacksExamining /tmp/powershell-6.0.0_alpha.9-1.el7.centos.x86_64.rpm: powershell-6.0.0_alpha.9-1.x86_64/tmp/powershell-6.0.0_alpha.9-1.el7.centos.x86_64.rpm: does not update installed package.等安装完成之后就可以直接使用powershell了[root@sydnagios ~]# powershellPowerShellCopyright (C) 2016 Microsoft Corporation. All rights reserved.PS /root>随便执行几条命令试试比较有趣的是, 我确实可以用ps命令导出结果,甚至也能导入,不过导入的结果不像window里面把所有的内容自动作为属性来保存,而是整个字符串作为一个属性,如果要处理这个文件的内容,我还是得和Linux一样去处理字符串,powershell的对象特性完全没有体现出来PS /root> get-process | out-file /tmp/test.csvPS /root> $a=import-csv /tmp/test.csvWARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers.PS /root> ¥ PS /root> $a | gm TypeName: System.Management.Automation.PSCustomObjectName MemberType Definition---- ---------- ----------Equals Method bool Equals(System.Object obj)GetHashCode Method int GetHashCode()GetType Method type GetType()ToString Method string ToString()H1 NoteProperty string H1=Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName另外一个豆子很期待的功能是远程操作,可惜invoke-command 这个命令根本就不存在,enter-pssession虽然存在,但是执行会报错,找不到对应的dll文件。我尝试谷歌了一下这个文件,一条线索都没有,估计太新了,还没有人遇见过这个问题。PS /root> Enter-PSSession -ComputerName sydit01 -Credential ominicomyliWindows PowerShell credential requestEnter your credentials.Password for user ominicomyli: **********Enter-PSSession : Unable to load DLL 'libpsrpclient': The specified module could not be found.(Exception from HRESULT: 0x8007007E)At line:1 char:1+ Enter-PSSession -ComputerName sydit01 -Credential ominicomyli+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Enter-PSSession], DllNotFoundException + FullyQualifiedErrorId : System.DllNotFoundException,Microsoft.PowerShell.Commands.EnterPSSessionCommand总之呢,很开心看见PS开源,也能够在*ix上执行,不过现在模块很少,命令总共才300多条,加上各种bug,还不太实用。希望成熟的版本能尽快出来,这样在苹果和Linux下也能远程的管理Windows了。


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:08pm
栏目列表