如何使用 PowerShell 在具有管理员权限的远程计算机上运行命令(例如:以管理员身份运行)。
到目前为止我已经尝试过
start-process powershell.exe -verb runas -argumentlists ".\test.ps1"
Run Code Online (Sandbox Code Playgroud)
这是失败的。
我想知道是否有一个 cmd 可以将现有证书从一个商店复制到另一个商店。我正在尝试将证书从用户中间证书颁发机构存储 (certutils -user -store ca fqdn-HOST-CA) 复制到机器的受信任根证书颁发机构存储 (certutils -store root fqdn-HOST-CA)。我尝试将 cmds 与 -addstore 一起使用,但没有用!!
certutil.exe -addstore root | certutil.exe -store -user ca fqdn-HOST-CA
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?谢谢
powershell windows-7 batch windows-command-prompt certificate-authority
在 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按照这个: …
我最近在 2 个不同的位置移动了很多很多文件。它是完全相同的数据集,使用相同的 robocopy 命令,但在我们总部的 Windows Server 2012 R2 上花费不到 30 分钟(使用 PowerShell v4)在 Windows Server 2008 R2 SP 1(PowerShell v2)上花费了大约 15 小时) 在我们 ISP 的服务器中心。两台服务器中的后者实际上有更多的 RAM 和 CPU(实际上是后者的两倍:512 GB 内存,64 核)。
两个任务之间唯一的另一个明显的硬件差异(对我而言)是在 2012 服务器上我将数据从本地磁盘移动到 SAN 卷,而在 2008 R2 服务器上它是跨 SAN(从 LUN 到 LUN)。我不认为这是罪魁祸首,因为源卷和目标卷之间的 iSCSI 带宽在每台机器上都是相同的。
也许我遗漏了一些东西,所以我想把它放在这里,看看你们都有什么见解。
powershell robocopy file-transfer windows-server-2008-r2 windows-server-2012-r2
Powershell 有一个Get-TlsCipherSutecmdlet,可返回有关 TLS 可以使用哪些密码的信息。
输出包括一个Protocols似乎被设置为数字数组的字段,例如:
PS C:\>Get-TlsCipherSuite -Name "AES"
KeyType : 0
Certificate : ECDSA
MaximumExchangeLength : 65536
MinimumExchangeLength : 0
Exchange : ECDH
HashLength : 0
Hash :
CipherBlockLength : 16
CipherLength : 256
BaseCipherSuite : 49196
CipherSuite : 49196
Cipher : AES
Name : TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
Protocols : {771, 65277}
Run Code Online (Sandbox Code Playgroud)
Protocols作为每个密码套件(例如,771和652677)的字段值的数字的含义是什么?
注意:如果您去探索,请注意此命令的输出似乎与 不符select,请参阅https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/16511008-get-tlsciphersuite-does-not -输出-表现良好-ob
powershell ×10
windows ×2
activesync ×1
batch ×1
certificate ×1
openssl ×1
robocopy ×1
scripting ×1
ssl ×1
windows-7 ×1