小编exp*_*001的帖子

连接网络路径+变量

如何将此路径与此变量连接起来?

$file = "My file 01.txt" #The file name contains spaces

$readfile = gc "\\server01\folder01\" + ($file) #It doesn't work
Run Code Online (Sandbox Code Playgroud)

谢谢

powershell

47
推荐指数
1
解决办法
7万
查看次数

创建一个数组,哈希表和字典?

创建数组,哈希表和字典的正确方法是什么?

$array = [System.Collections.ArrayList]@()
Run Code Online (Sandbox Code Playgroud)

$array.GetType() 返回ArrayList,好的.

$hashtable = [System.Collections.Hashtable]
Run Code Online (Sandbox Code Playgroud)

$hashtable.GetType() 返回RuntimeType,不行.

$dictionary = ? 
Run Code Online (Sandbox Code Playgroud)

如何使用这种.NET方式创建字典?

字典和散列表有什么区别?我不确定何时应该使用其中一个.

powershell

41
推荐指数
2
解决办法
6万
查看次数

Write-Host =>导出到文件

我有一个脚本,有一些命令,如Write-Host "Server1".如何将其导出到文件?

当我尝试script > export.txt它时,它没有用.

powershell powershell-2.0 powershell-1.0

15
推荐指数
3
解决办法
10万
查看次数

将“写主机”与变量对齐

这是我的代码:

Write-Host "Field 1 : " $variable1  
Write-Host "Field 2 : " $variable2
Write-Host "Field 3 : " $variable3
Write-Host "Field 4 : " $variable4
Run Code Online (Sandbox Code Playgroud)

我得到如下输出:

   Field 1    : " $variable1    
   Field 2          : " $variable2
   Field 3      : " $variable3
   Field 4           : " $variable4
Run Code Online (Sandbox Code Playgroud)

我怎样才能对齐它们?

谢谢

powershell powershell-2.0

-1
推荐指数
1
解决办法
1万
查看次数