我有一个正在开发的 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) 我需要更改 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 进行相同的更改吗? …
在 Register-ClusteredScheduledTask 下面执行时,我收到此错误。
Register-ClusteredScheduledTask -TaskName $ClusterTaskName -TaskType AnyNode -Xml $TaskXML | 出空
Register-ClusteredScheduledTask : The parameter is incorrect.
At C:\Setup-Scheduler.ps1:215 char:5
+ Register-ClusteredScheduledTask -TaskName $ClusterTaskName -TaskT ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: InvalidArgument: (PS_ClusteredScheduledTask:Root/Microsoft/...ed
ScheduledTask) [Register-ClusteredScheduledTask], CimException
+ FullyQualifiedErrorId: HRESULT 0x80070057,Register-ClusteredScheduledTask
Run Code Online (Sandbox Code Playgroud)
我的 XML
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo />
<Triggers>
<TimeTrigger>
<Repetition>
<Interval>PT15M</Interval>
<StopAtDurationEnd>false</StopAtDurationEnd>
</Repetition>
<StartBoundary>2016-11-08T13:26:00</StartBoundary>
<Enabled>true</Enabled>
</TimeTrigger>
<TimeTrigger>
<Repetition>
<Interval>PT5H</Interval>
<StopAtDurationEnd>false</StopAtDurationEnd>
</Repetition>
<StartBoundary>2016-11-09T19:29:00</StartBoundary>
<Enabled>true</Enabled>
</TimeTrigger>
<CalendarTrigger>
<StartBoundary>2016-11-09T19:29:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
<CalendarTrigger>
<StartBoundary>2016-11-09T00:00:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByMonth>
<DaysOfMonth>
<Day>9</Day> …Run Code Online (Sandbox Code Playgroud) 我正在创建一个在远程服务器上使用多个“Invoke-Command -asjob”的脚本,但在测试 While-Loop 时我不得不停止它。但是,当我现在在目标服务器上尝试 Invoke-Command -asjob 时,它返回状态为 failed 的作业。当我收到作业时,它返回此错误:
The WS-Management service cannot process the request. This user has exceeded the maximum number of concurrent shells allowed for this plugin. Close at least one open shell or raise the plugin quota for this user.
+ FullyQualifiedErrorId : -2144108060,PSSessionStateBroken
Run Code Online (Sandbox Code Playgroud)
当我执行 Get-PSSession 时,没有列出,所以我不能使用 Remove-PSSession(这是 Google 迄今为止唯一的建议)。
这是它基本上执行的内容:
While ($True)
{
Invoke-Command -Computername $RemoteServer -AsJob {Get-ChildItem}
}
Run Code Online (Sandbox Code Playgroud)
我打破了它并做了Get-Job | Remove-Job 删除了所有作业,但我仍然无法在远程服务器上启动 Invoke-Command -AsJob。
我还在远程服务器上重新启动了 WSMAN 服务(通过使用 RDP 登录),但它不起作用。
我正在尝试创建一个在 Windows Server 2012 R2 Core 上启动时运行的作业。该作业运行连接到网络共享的脚本,然后安装位于该共享上的 VHD。
脚本本身可以工作,当使用-RunNow参数注册时,作业会被触发并按预期运行。使用Start-JobCmdlet运行作业也可以正常工作。
但是,作业不会像触发器中指定的那样在启动时触发。
我为创建工作所做的工作:
$Trigger = New-JobTrigger -AtStartup
$JobOptions = New-ScheduledJobOption -RunElevated -RequireNetwork
Register-ScheduledJob -FilePath C:\Scripts\Test.ps1 -Name Test -Trigger $Trigger -ScheduledJobOption $JobOptions -RunNow
Run Code Online (Sandbox Code Playgroud)
这样做后,我可以清楚地看到它的工作结果。但是当重新启动服务器时,结果不存在,但作业说它是在重新启动后不久运行的。
根据本指南,我尝试创建用于签署 PowerShell 脚本的证书:
CD C:\OpenSSL-Win32\bin
REM Create the key for the Certificate Authority. 2048 is the bit encryptiong, you can set it whatever you want
openssl genrsa -out C:\Test\ca.key 2048
openssl req -config C:\OpenSSL-Win32\bin\openssl.cfg -new -x509 -days 1826 -key C:\Test\ca.key -out C:\Test\ca.crt
REM Now I'm creating the private key that will be for the actual code signing cert
openssl genrsa -out C:\Test\codesign.key 2048
openssl req -config C:\OpenSSL-Win32\bin\openssl.cfg -new -key C:\Test\codesign.key -reqexts v3_req -out C:\Test\codesign.csr
openssl x509 -req -days …Run Code Online (Sandbox Code Playgroud) 环境:Office 365 在线版。交换 v15.1.933.16。
我们的一位全球管理员通过交换管理中心在移动设备上执行远程擦除,然后从 EAC 中“删除”了该设备。因此,不再可能在 GUI 中确定擦除是否成功。
任何熟悉用于检查擦除命令状态的 cmdlet 的人吗?到目前为止,我的搜索没有找到任何东西。谢谢
编辑:谢谢 BasitanW,但是我应该更清楚地表明管理员在请求擦除后删除了该设备。Exchange 管理中心中没有设备可见,并且 Get-MobileDevice 命令无法为 PS 中的此邮箱生成结果。
我创建了一个小脚本来将名为 pssfulllocation 的 Active Directory pc 属性值从一台 pc 传输到另一台 pc。
为了实现这一点,我必须使用类型转换+拆分..
这是有效的脚本
$oldpc=read-host "Enter old pc name"
$newpc=read-host "Enter new pc name"
$my=Get-ADComputer -Identity $oldpc -Properties * | select pssfulllocation
$itemcast=[string]$my
$b = $itemcast.Split("=")[1]
$c=$b.Split("}")[0]
Set-ADComputer -identity $newpc -Replace @{pSSFullLocation="$c"}
Run Code Online (Sandbox Code Playgroud)
并且输出将很好地完成预期的工作..以这种方式..这是期望的结果..
但是,如果我不按照以下脚本使用类型转换 + 拆分--
$oldpc=read-host "Enter old pc name"
$newpc=read-host "Enter new pc name"
$my=Get-ADComputer -Identity $oldpc -Properties * | select pssfulllocation
Set-ADComputer -identity $newpc -Replace @{pSSFullLocation="$my"}
Run Code Online (Sandbox Code Playgroud)
输出在下面..这不是我想要的..
简而言之,如果我不使用类型转换 + 拆分输出将添加为 @{pSSFullLocation=C/BRU/B/0/ADM/1 但它只能添加为 C/BRU/B/0/ADM/1按照这个: …
我相当确定我已经发现了一个错误,但我正在尝试理解它并进行完整性检查。
一种策略,如果请求正在查找AND客户端 IP 不在特定子网中的特定CNAME记录,则该策略匹配并生成一条记录,该记录的目标不在策略涵盖范围内且不存在于范围内。
example.comexample.com默认范围内的记录:
testme IN A 10.1.2.3testOther IN A 10.11.11.11TesterScopeTesterScope:
testme IN CNAME testOther.example.com.MySubnet包含10.8.8.0/24EQ客户端子网MyQRP使用以下配置查询解析策略:
AndTesterScopeEQ,testme.example.com.EQ,MySubnet这将产生预期的结果,即:
testme.example.com从IP内MySubnet(应匹配),它会返回正确(和解决)的CNAME记录,即使CNAME必须在默认范围(该QRP特别是当应该只匹配来解决FQDN是testme.example.com不是testOther.example.com)。因此,结果是10.11.11.11,这是正确的。 …domain-name-system powershell active-directory windows-server-2016 dns-policies
我正在使用 Server 2012R2 服务器。我想使用PowerShellget-dnsserverresourcerecord的dns 服务器模块中的 comdlets 。
它在 ISE 或模块列表中不可用。
我有 PowerShell 4.0 版。我在服务器 2012r2 上运行。我在哪里可以找到这个模块?是否可以下载或启用此模块?我查看了很多文档和帖子,它们的编写方式都表明应该安装模块。
我的计划是使用此服务器对另一台运行 DNS 服务器的 2012r2 服务器执行 DNS 命令。该服务器本身没有安装 DNS 服务器。
谢谢你。
domain-name-system powershell windows-server-2012-r2 powershell-v4.0
powershell ×10
activesync ×1
certificate ×1
dns-policies ×1
http ×1
openssl ×1
scripting ×1
windows ×1