仍在学习并且我很难尝试将信息输出到文件:不接受输出文件路径。
我的位置是PS Cert:\localmachine,这里是整个命令:
$cert = Get-ChildItem -Path cert: -Recurse | where { $_.notafter -le (get-date).AddDays(75) -AND $_.notafter -gt (get-date)} | select notafter, issuer, thumbprint, subject | sort-object notafter
$cert | Out-File -FilePath \\ad.dcpds.cpms.osd.mil\WinAdm\Logs\Expiring_Certificates\$hostname.log
Run Code Online (Sandbox Code Playgroud)
我收到的错误消息是:
Out-File : Cannot open file because the current provider (Microsoft.PowerShell.Security\Certificate) cannot open a file.
我有两个安全组,用于组策略安全筛选.这些用于每月错开Windows更新.已经出现的问题是,我无法跟上上线的新服务器.所以我想自动化一个powershell脚本,它会通过电子邮件向我发送一组在A组或B组中找不到的服务器.我有一些代码,但我似乎无法理解它.
#Grab the computer names from the first security group
$group1 = Get-ADGroup -Identity 'Every Day WSUS 3am Install'
$members1 = Get-ADGroupMember -Identity $group1 | select -Expand Name
#Grab the computer names from the second security group
$group2 = Get-ADGroup -Identity 'Every Day WSUS 6am Install'
$members2 = Get-ADGroupMember -Identity $group2 | select -Expand Name
#grab all computer obejects that are servers from AD and list the names not found in either security group
(Get-ADComputer -LDAPFilter "(&(objectcategory=computer)(OperatingSystem=*server*))").Name | ? { …Run Code Online (Sandbox Code Playgroud) powershell ×2