小编res*_*101的帖子

powershell:用参数启动程序的脚本?

当我在下面运行Powershell脚本时,我收到以下错误.如何通过参数PowerShell运行程序?该脚本将是一个组策略登录.

Invoke-Expression:找不到接受参数'\ TBHSERVER\NETLOGON\BGInfo\BGIFILE.bgi/timer:0/s ilent/nolicprompt'的位置参数.在X:\ Systems\scripts\PowerShell\UpdateDesktopWithBGInfo.ps1:6 char:18 + Invoke-Expression <<<< $ logonpath $ ArguList + CategoryInfo:InvalidArgument :( :) [Invoke-Expression],ParameterBindingException + FullyQualifiedErrorId:PositionalParameterNotFound, Microsoft.PowerShell.Commands.InvokeExpressionCommand

$LogonPath = $env:LOGONSERVER + "\NETLOGON\BGInfo\Bginfo.exe" 
$ArguList = $env:LOGONSERVER + '\NETLOGON\BGInfo\BGIFILE.bgi /timer:0 /silent /nolicprompt '
invoke-command $LogonPath
Invoke-Expression $logonpath $ArguList
Run Code Online (Sandbox Code Playgroud)

authentication powershell group-policy invoke-command

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

如何在PowerShell中从此数组中获取唯一值?

为什么以下代码会返回$null?我试图存储唯一的值.

$DailyPathsToDelete = @("C:\temp\IMG000483\","C:\temp\IMG000483\")
$DailyPathsToDelete = Select-Object $DailyPathsToDelete -Unique 
Run Code Online (Sandbox Code Playgroud)

string powershell unique

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

在PowerShell中设置System.DateTime对象的时间

我希望使用$ time的时间设置下面的System.DateTime对象:

$CurrentTime = (date)
$Time = "9:00"
Run Code Online (Sandbox Code Playgroud)

如何从$ CurrentTime获取日期,但是从$ time开始的小时,分​​钟,秒?

powershell time date

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

powershell:get-psdrive和where-object

我试图在Windows 2008服务器上找到不是"C,E,L,S,T,W"的每个驱动器号.谁能告诉我我的逻辑中的错误或我怎么能这样做呢?

[char[]]”CELSTW” | Where-Object {!(Get-PSDrive $_ )} 
Run Code Online (Sandbox Code Playgroud)

windows powershell logic

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

比较2个文件夹并将路径保存到变量中?

我被赋予了比较2个文件夹FolderA和FolderB并注意A中存在但不存在于B中的任何文件的任务.

很抱歉没有完全解释自己.如果我解释一下情况,也许会有所帮助.公司销售人员离开我们公司去竞争对手.他在他的工作笔记本电脑本地硬盘上有文件.我们正在尝试确定他的计算机上是否存在任何文件但不存在于共享网络文件夹中.

我需要生成一个列表,列出他的笔记本电脑上但不在共享网络位置的任何文件(及其路径).笔记本电脑本地硬盘驱动器和共享网络位置之间的文件结构是不同的.最好的方法是什么?

$folderAcontent = "C:\temp\test1" 
$folderBcontent = "C:\temp\test2"

$FolderAContents = Get-ChildItem $folderAcontent -Recurse | where-object {!$_.PSIsContainer}
$FolderBContents = Get-ChildItem $folderBcontent -Recurse | where-object {!$_.PSIsContainer}

$FolderList = Compare-Object -ReferenceObject ($FolderAContents ) -DifferenceObject ($FolderBContents) -Property name
$FolderList | fl * 
Run Code Online (Sandbox Code Playgroud)

powershell compare get-childitem

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

Powershell如果语句没有执行

我有跟随代码片段的PowerShell脚本和嵌套的if语句没有被执行.你能告诉我为什么吗 ?我最近又回到了编程游戏,所以它可能很简单

$false. 
$IgnoreThisLine = $false
$tmpString = "(DATUM CTR OF BLADE)"
$EndOfDescription = $null 
$cncPrograms ="(165756 SIDE 1)"

if ($IgnoreThisLine = $false ) {
    If ($tmpString -match '\(') {
        $EndOfDescription =  $false
        $cncPrograms = $tmpString 
        }
    else {
    $EndOfDescription = $true               
    }
}
Run Code Online (Sandbox Code Playgroud)

variables powershell if-statement conditional-statements

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