Powershell core 在Linux上试用

微软终于宣布Powershell开源了,也就是可以在Linux和OSX上执行了。

豆子参考这篇博文,简单的测试了一下。

http://www.howtogeek.com/267858/how-to-install-microsoft-powershell-on-linux-or-os-x/


找了一个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.rpm
Loaded plugins: fastestmirror, langpacks
Examining /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 ~]# powershell
PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS /root>


随便执行几条命令试试


比较有趣的是, 我确实可以用ps命令导出结果,甚至也能导入,不过导入的结果不像window里面把所有的内容自动作为属性来保存,而是整个字符串作为一个属性,如果要处理这个文件的内容,我还是得和Linux一样去处理字符串,powershell的对象特性完全没有体现出来


PS /root> get-process | out-file /tmp/test.csv
PS /root> $a=import-csv /tmp/test.csv
WARNING: 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.PSCustomObject
Name        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 ominicom\yli
Windows PowerShell credential request
Enter your credentials.
Password for user ominicom\yli: **********
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 ominicom\yli
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Enter-PSSession], DllNotFoundException
    + FullyQualifiedErrorId : System.DllNotFoundException,Microsoft.PowerShell.Commands.EnterPSSessionCommand


总之呢,很开心看见PS开源,也能够在*ix上执行,不过现在模块很少,命令总共才300多条,加上各种bug,还不太实用。希望成熟的版本能尽快出来,这样在苹果和Linux下也能远程的管理Windows了。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值