Linux下使用Powershell管理的对象应该是比Window下的少很多。毕竟Powershell是Window原生的。
之前的文字已经开始接触到Linux下使用Powershell的基础,并且成功安装了Powerhell。在Linux下运行Powershell之需要在原来的终端下输入pwsh命令就可以了。先运行以下get-host查看以下版本信息。输出如下:
S /home/wangcc> get-host
Name : ConsoleHost
Version : 7.2.4
InstanceId : cd465bc3-4644-4fbc-b0c8-56202076d54a
UI : System.Management.Automation.Internal.Host.InternalHostUserI
nterface
CurrentCulture : zh-CN
CurrentUICulture : zh-CN
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
从输出我们可以看到默认安装的应该是最新的发行版本。
使用get-psdrive看看Linux下支持的Powershell驱动有那些
PS /home/wangcc> Get-PSDrive
Name Used (GB) Free (GB) Provider Root
---- --------- --------- -------- ----
/ 12.87 26.25 FileSystem /
Alias Alias
Env Environment
Function Function
Temp 12.87 26.25 FileSystem /tmp/
Variable Variable
在Linux下进入这些PSDrive,发现和Windows下进入PSDrive是不一样的,当用ls查看这些驱动时,在window下查看的是这些虚拟驱动下的内容,而在Linux下查看的其实是当前目录下的文件内容。
在实际的使用中,可以多动手找出两个OS 下的Powershell的cmdlet的异同。