我在一个域上有 2 个帐户。
我可以用一个帐户登录 citrix 虚拟桌面,但另一个帐户在我第一次更改密码之前不会让我登录任何东西。我是远程的,所以如果不先更改密码,我就无法登录到我有权访问的服务器的 RDP 会话。
是否可以在我知道密码但无法使用该帐户登录任何内容的其他帐户上更改我的密码?
我正在尝试比较包含通配符的字符串。
("www.mysite.*" -match '`*')
Run Code Online (Sandbox Code Playgroud)
但是有些东西不起作用,因为我总是得到真实的回应,例如
("www.mysite.com" -match '`*')
Run Code Online (Sandbox Code Playgroud)
我试过使用 -contains 代替,但我总是错误的。
上周我开发了一个脚本来检查是否在指定的机器上启用了 psremoting。本周我开始编写一个可以在指定机器上启用 psremoting 的脚本,但我无法让 psexec 在 powershell 中运行(另外,是的,我知道可以通过组策略启用 psremoting)。这是我的脚本:
$input = Read-Host @"
Select Option
(1)Manually enter computer(s)
(2)Retrieve computer(s) from file
Option
"@
If ($input -eq 1){
$count = Read-Host "How many computers"
$Computers = 1..$count
$b=0;$c=1; ForEach ($Computer in $Computers) {$Computers[$b] = Read-Host "Computer" $c; $b++; $c++}
} ElseIF ($input-eq 2) {
$Computers = Read-Host "File"
$Computers = Get-Content $Computers
} Else {
write-host "Invalid Option"
Exit
}
cls
$User = Read-Host "Enter username"
$Pass = Read-Host "Enter …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Powershell 来检测某些硬件故障。
Powershell 是否可以连接到正常的 HP 事件/日志/警报以检测驱动器是否出现故障?
我有一个正在开发的 powershell 脚本,它将通过代理从 HTTP 服务器下载文件,并在服务器上包含 UN/PW。
我的文件下载正常,但有些文件非常大,所以我一直在添加一个函数来检查文件是否已更改(检查大小)。这适用于第一个文件。但它在这一行的第二个文件上超时:
$test = $wc2.OpenRead($source) | Out-Null)
Run Code Online (Sandbox Code Playgroud)
下面列出了我的脚本的代码(不包括凭据)。我很感激有关如何正确关闭连接(因为我怀疑没有发生)或如何使用 Powershell 通过 HTTP 获取远程文件大小的建议。
Function getWebClient {
$webClient = new-object System.Net.WebClient
$pxy = new-object System.Net.WebProxy $proxy
$pxy.Credentials = New-Object System.Net.NetworkCredential ("tnad\$proxy_un", "$proxy_pw")
$webClient.proxy=$pxy
$webClient.Headers.Add("user-agent", "Windows Powershell WebClient Header")
$WebClient.Credentials = New-Object System.Net.Networkcredential($un, $pw)
return $WebClient
}
foreach ($ds in $datasetsTest) {
Write-Host "Checking: $ds"
$source = "$server$ds"
$dest = "$destFolder$ds"
#Test whether the destination file already exists, if it exists, compare file sizes.
$destExists = Test-Path $dest …Run Code Online (Sandbox Code Playgroud) 我使用了很多文件夹共享,但是有一些其他进程打开了一堆锁定的文件。
我需要关闭这些文件。到目前为止,我一直在使用 MMC - 系统工具 - 共享文件夹 - 打开文件。
如果我可以使用 PowerShell 过滤由OpenFiles.exe检索到的列表/表,并且一旦我获得文件 ID,使用net file /close或其他一些具有类似效果的 PS 本机方法将其关闭,那将会方便得多。
我是 PowerShell 的新手,所以我想知道是否有办法创建一个 PS 脚本来接收文件的路径,然后使用文件 ID 来关闭该文件?
我需要更改 TCP InitialCongestionWindow 的默认值
我阅读了这个文件:https : //www.iispeed.com/blog/windows-server-2012-and-tcp-slow-start
我在我们的 hyper-v 托管虚拟服务器 2012 R2 上进行了尝试。
PS C:\>Set-NetTCPSetting -SettingName Custom -InitialCongestionWindow 10 -CongestionProvider CTCP
Run Code Online (Sandbox Code Playgroud)
我有错误:
Set-NetTCPSetting : No MSFT_NetTCPSetting objects found with property 'SettingName' equal to 'Custom'. Verify the valu
e of the property and retry.
At line:1 char:1
+ Set-NetTCPSetting -SettingName Custom -InitialCongestionWindow 10 -CongestionPro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Custom:String) [Set-NetTCPSetting], CimJobException
+ FullyQualifiedErrorId : CmdletizationQuery_NotFound_SettingName,Set-NetTCPSetting
Run Code Online (Sandbox Code Playgroud)
问题是我如何才能完成 IISspeed 文档所讲述的内容?如果我在 Hyper-v 机器上更改此设置,我是否也需要在 hypers-v 主机上更改此设置才能真正发挥作用?
我也应该对 SSL 端口 443 进行相同的更改吗? …
我是 Windows Server 的新手,我很好奇:有没有办法使用 PowerShell 或批处理文件将组安全设置转储到文本文件?谢谢!
我有一台装有 Powershell V4.0 的 Windows 2008 R2 服务器
我得到了一个非常简单的脚本 test.ps1,其中包含以下内容:
Write-host "Hello world!"
Run Code Online (Sandbox Code Playgroud)
我从一个 powershell 提示符调用这个脚本,如下所示:
measure-command { powershell.exe -file .\test.ps1 }
Run Code Online (Sandbox Code Playgroud)
如您所见,我获得了极高的价值:
Days : 0
Hours : 0
Minutes : 0
Seconds : 7
Milliseconds : 992
Ticks : 79922815
TotalDays : 9,25032581018519E-05
TotalHours : 0,00222007819444444
TotalMinutes : 0,133204691666667
TotalSeconds : 7,9922815
TotalMilliseconds : 7992,2815
Run Code Online (Sandbox Code Playgroud)
或者
Days : 0
Hours : 0
Minutes : 0
Seconds : 4
Milliseconds : 655
Ticks : 46556579
TotalDays : 5,38849293981481E-05
TotalHours : …Run Code Online (Sandbox Code Playgroud) 我现在是我公司离职脚本的自豪拥有者(耶!)。我一直在检查代码和测试,我注意到在某些用户的主文件夹中,我达到了 PowerShell 的 260 个字符限制。这是一个问题,因为我们的政策规定,离开公司的任何处于“诉讼保留”状态的人都需要压缩和存储他们的整个主文件夹,直到合法释放它(换句话说就是永远)。脚本的其余部分运行良好并处理其他所有事情,因此我希望此过程保留在 PowerShell 中。
我尝试了很多方法/方法/解决方法,但我还没有找到一种有效的方法。这是我尝试过的:
AlphaFS:可以获得所有文件名,但是当我将输出发送到本机 cmdlet 时会
窒息(并不奇怪)AlphaFS 压缩:不是递归
7-Zip:不能正确保留时间戳
ICSharpCode.SharpZipLib:达到 PS 字符限制
*编辑:我也尝试过QuickIO.NET,但没有通过压缩方法通过 PS 限制。
*Edit2:尝试System.IO.Compression.FileSystem - 达到 PS 字符限制
不幸的是,我不能发布代码,但这个想法很简单。
主文件夹 --> PowerShell --> 压缩文件
我可以在脚本中加载我可能需要的任何模块,但它必须保留在 PowerShell 中,并且文件夹内容需要压缩到一个文件中。我希望这甚至是可能的。
任何帮助,将不胜感激。
谢谢