Tag: powershell v1.0

PowerShell通用集合

我一直在推进到PowerShell中的.NET框架,我碰到了一些我不明白的东西。 这工作正常: $foo = New-Object "System.Collections.Generic.Dictionary“2[System.String,System.String]" $foo.Add("FOO", "BAR") $foo Key Value — —– FOO BAR 但是,这不是: $bar = New-Object "System.Collections.Generic.SortedDictionary“2[System.String,System.String]" New-Object : Cannot find type [System.Collections.Generic.SortedDictionary`2[System.String,System.String]]: make sure t he assembly containing this type is loaded. At line:1 char:18 + $bar = New-Object <<<< "System.Collections.Generic.SortedDictionary“2[System.String,System.String]" 他们都在同一个集会,所以我错过了什么? 正如在答案中指出的,这几乎只是PowerShell v1的一个问题。

复制项目复制目录以及内容到UNCpath

我试图采取一个文件夹的内容,并将其复制到另一个unis powershell 1.0。 很简单的东西,所有工作正常使用Copy-Item $from $to -recurse如果我从本地文件夹复制到本地文件夹,但是如果$到variables是一个UNCpath它似乎复制$从目录,而不是只是其内容 例如 $from = "c:\temp\rhysc\" $to = "\\OtherMachineName\ShareFolder\" Copy-Item $from $to -recurse ..结束了创build一个文件夹`\ OtherMachineName \ ShareFolder \ rhysc`,而不是只复制文件夹的内容。 我想维护我复制的from目录的结构,所以我在pipe道上的基本尝试没有工作(一切都被转储到$to文件夹的根目录) Get-ChildItem $from -recurse | Copy-Item -destination $to

我如何find执行脚本的源代码path?

我想能够告诉我的执行脚本从哪个path运行。 这通常不会是$密码。 我需要调用与脚本相关的文件夹结构中的其他脚本,并且可以对path进行硬编码,但是当试图从“dev”升级到“test”时,这样做会让人感到不愉快和痛苦“生产”。

如何使用PowerShell删除文件上的ReadOnly属性?

如何使用PowerShell(版本1.0)脚本删除文件上的ReadOnly属性?