我是powershell的初学者,我怀疑这将是一个简单的问题.我正在尝试执行以下命令,但它不返回任何结果,我不明白为什么.
我正在尝试获取bcdedit当前部分的描述.如果我做:
bcdedit /enum | select-string "identifier.*current" -context 0,3
Run Code Online (Sandbox Code Playgroud)
它返回以下内容:
> identifier {current}
device partition=C:
path \WINDOWS\system32\winload.exe
description Windows 8.1
Run Code Online (Sandbox Code Playgroud)
那么为什么以下不归description Windows 8.1呢?
bcdedit /enum | select-string "identifier.*current" -context 0,3 | select-string "description"
Run Code Online (Sandbox Code Playgroud)
相反,它根本不返回任何东西.
任何有关这方面的信息将不胜感激.
我想将多个RSS订阅源合并到一个订阅源中,删除任何重复项.具体来说,我有兴趣合并我感兴趣的标签的feed .
[快速搜索出现了一些有希望的链接,我现在没有时间访问]
从广义上讲,理想的读者会列出网站上所有可用的标签并打开和关闭它们,让我可以探索可用的内容,跟踪我访问过的问题,有趣的信息源的新答案等,等等...虽然我不认为现在存在这样的事情.
当我随机浏览网站并查看我认为有趣的问题时,我不可避免地会发现"哦,是的,几天前,当我第一次看到它时,那个看起来很有趣,并且自那以后一直没有更新".如果我的机器会跟踪这样的情况,那会好得多:)
更新:您现在可以使用"和","或"和"不"将多个标记合并为一个Feed:标记和标记或标记
当我运行以下操作时,PowerShell会挂起,等待对话框关闭,即使对话框永远不会显示:
[void] [Reflection.Assembly]::LoadWithPartialName( 'System.Windows.Forms' )
$d = New-Object Windows.Forms.OpenFileDialog
$d.ShowDialog( )
Run Code Online (Sandbox Code Playgroud)
调用ShowDialog上Windows.Forms.Form正常工作.我也尝试创建一个Form并将其作为父项传递$d.ShowDialog,但结果没有什么不同.
我需要将大量文件复制到备份文件夹,但我想保持它们的相对路径.我只需要特定的文件; 即
C:\scripts\folder\File.ext1
C:\scripts\folder2\file2.ext2
C:\scripts\file3.ext1
Run Code Online (Sandbox Code Playgroud)
但我只需要像这样复制ext1文件:
C:\backup\folder\File.ext1.bak
C:\backup\file3.ext1.bak
Run Code Online (Sandbox Code Playgroud)
源路径具有多个深度.这就是我要复制文件的方法:
$files = gci -path C:\scripts\ -recurse -include *.ext1
$files | % { Copy-Item $_ "$($_).bak"; move-item $_ -destination C:\backup\ }
Run Code Online (Sandbox Code Playgroud)
这只是将所有文件转储到C:\ backup \中,并且似乎没有获得任何路径.不确定该部分将如何完成.
我正在运行一个脚本,其中有多个环境,可以从弹出的窗口中选择.我遇到的唯一问题是当我想要设置脚本从我创建的源函数复制并立即将它放入多个位置时.
我需要帮助的部分代码发布在下面.
$Source = Select-Boss
$destination = 'D:\parts','D:\labor','D:\time','D:\money'
"Calling Copy-Item with parameters source: '$source', destination: '$destination'."
Copy-Item -Path $source -Destination $destination
Run Code Online (Sandbox Code Playgroud)
以下部分是如何在脚本中设置其余复制功能,以便您更好地了解主要部分副本的内容.
$Source = Select-Boss
$destination = 'D:\parts'
"Calling Copy-Item with parameters source: '$source', destination: '$destination'."
Copy-Item -Path $source -Destination $destination
Run Code Online (Sandbox Code Playgroud)
但是对于一个特定的部分,我需要将它复制到多个位置.我需要这样做,因为我不必更改我登录的服务器并转到另一个服务器.这一切都在一个地方完成,我希望让事情变得更容易,而不是写一大堆小编码去复制并保存在文件夹中.
我正在尝试创建一个PowerShell脚本,它将在文件夹中搜索包含某个文件掩码的文件名.文件夹中的所有文件都具有类似的格式*yyyyMd*.txt.
我制作了一个剧本:
[String]$date = $(get-date -format yyyyMd)
$date1 = $date.ToString
Get-ChildItem C:\Users\pelam\Desktop\DOM | Where-Object {$_.Name -like '*$date1*'}
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用..
有人可以帮忙吗?似乎问题是日期变量不正确,因为当我硬编码下面的内容时,它的工作原理如下:
Get-ChildItem C:\Users\pelam\Desktop\DOM | Where-Object {$_.Name -like '*20141013*'}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用PowerShell(版本2)Start-Process并重命名新启动的窗口标题。我的以下代码段运行良好,它启动了一个新的PowerShell窗口并尾部记录了日志($c包含尾部的日志文件):-
Start-Process powershell.exe -Argument "Get-Content", $c, "-wait"
Run Code Online (Sandbox Code Playgroud)
我不确定如何添加以下内容,以便可以更改新启动的窗口标题。
$host.ui.RawUI.WindowTitle = 'New window title rename example text'
Run Code Online (Sandbox Code Playgroud)
干杯。
我是PS的新手,已经获得了一个可以运行的脚本.我做的第一件事是输入c:\powershell\ir.ps1.这似乎有效.然后在定义我的客户端目录之后,我应该只能输入诸如的函数ir-n.这在人员的办公桌上工作,告诉我该怎么做,但是我收到以下错误:
The term 'ir-n' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:5
+ ir-n <<<<
+ CategoryInfo : ObjectNotFound: (ir-n:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)
有什么简单的我可以做到让它运行?我看到ir.ps1文件中的函数,所以我知道它在那里.
我想更改INI文件中的一些值.不幸的是,我有2个不同部分的密钥,它们共享相同的名称但需要不同的值.我的代码使用了Get-IniContent函数from PsIni.
示例INI文件:
[PosScreen]
BitmapFile=C:\Temp\Random.bmp
Bitmap=1
[ControlScreen]
BitmapFile=C:\Temp\Random.bmp
Bitmap=1
Run Code Online (Sandbox Code Playgroud)
我需要将以上内容更改为以下内容:
[PosScreen]
BitmapFile=C:\Temp\FileC.bmp
Bitmap=1
[ControlScreen]
BitmapFile=C:\Temp\FileD.bmp
Bitmap=1
Run Code Online (Sandbox Code Playgroud)
我正在使用的PowerShell代码似乎工作,但它将每个值更改为"文件D".显然解析所有内容两次,每个部分的名称相同.
$NewFileC = "C:\Temp\FileC.bmp"
$NewFileD = "C:\Temp\FileD.bmp"
$POSIniContent = Get-IniContent "C:\scripts\Update-EnablerImage\WINSUITE.INI"
$BOIniContent = Get-IniContent "C:\scripts\Update-EnablerImage\WINSUITE.INI"
If ($POSIniContent["PosScreen"]["BitmapFile"] -ne $NewFileC) {
Get-Content "C:\scripts\Update-EnablerImage\WINSUITE.INI" |
ForEach-Object {$_ -replace "BitmapFile=.+" , "BitmapFile=$NewFileC" } |
Set-Content "C:\scripts\Update-EnablerImage\WINSUITE.INI"
}
If ($BOIniContent["ControlScreen"]["BitmapFile"] -ne $NewFileD) {
Get-Content "C:\scripts\Update-EnablerImage\WINSUITE.INI" |
ForEach-Object {$_ -replace "BitmapFile=.+" , "BitmapFile=$NewFileD" } |
Set-Content "C:\scripts\Update-EnablerImage\WINSUITE.INI"
}
Run Code Online (Sandbox Code Playgroud)
我的斗争是如何独立改变每一个.我是一个脚本新手,所以请求一些帮助.尝试使用条件逻辑(ForEach $line in $INIFile例如),但没有运气.