Articles of PowerShell

使用PowerShell获取Office 365 DNSlogging

过去,我一直在学习PowerShell来pipe理Office 365租赁,而不是使用Web界面。 在添加一个新域并确认域名的所有权之后(全部通过PowerShell完成),我想知道是否有一个cmdlet可以用来获取应该为要由Office 365pipe理的域configuration的区域logging。 收集创buildOffice 365 DNSlogging所需的信息说明如何使用Web界面获取这些信息,但我更愿意尽可能使用PowerShell进行操作。 目前,我可以使用Get-DkimSigningConfig来确定启用DKIM的正确的CNAMElogging,例如, Get-DkimSigningConfig -Identity contoso.com | fl Selector?CNAME 这通常应该是formsselector1-contoso-com._domainkey.contoso.onmicrosoft.com但我发现,我们的一个托pipe域的DKIM CNAME必须设置为selector1-contoso-com0i._domainkey.contoso.onmicrosoft.com (额外的0i )。 对于MXlogging,我期望它是contoso-com.mail.protection.outlook.com但我想确定,所以我想知道是否有一个PowerShell cmdlet或Azure对象列出的DNSlogging应该configuration为一个托pipe域(特别是用于MXlogging)。 我花了很多时间searchnetworking和微软自己的文档,但我只find了如何使用Web界面来确定这些信息的参考。

无法在Windows Server 2016无人参与安装中执行远程poweshell脚本

我正在尝试为Windows Server 2016无人参与安装创buildunattended.xml文件,在安装Windows之后,它应该执行位于远程samba共享上的一个powershell脚本。 我正在使用以下命令来运行存储在samba共享中的powershell脚本: cmd.exe /c "ECHO R | powershell.exe -ExecutionPolicy Unrestricted -File \\192.168.137.131\install\ConfigureRemotingForAnsible.ps1" 无人参与安装过程工作正常,但ConfigureRemotingForAnsible.ps1脚本执行失败,错误: The argument '\\192.168.137.131\install\ConfigureRemotingForAnsible.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter. 当我手动运行它时,相同的命令执行成功。 unattended.xml文件的相关部分: <settings pass="specialize"> <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <RunSynchronous> <RunSynchronousCommand wcm:action="add"> […]

TaskScheduler触发特定的任务

我有一个通过TaskScheduler运行的备份服务。 备份任务运行一个batch file,完成所有的魔术。 有时备份会失败,直到服务器变得没有响应才会填充日志表(这是一个不同的问题) 我试图创build一个单独的任务, 当备份任务失败时向我发送一封电子邮件。 到目前为止,我已经创build了一个PowerShell脚本,发送电子邮件没有问题。 该脚本通过“失败的备份电子邮件”任务被调用,没有任何问题。 我的问题是让电子邮件任务触发。 备份任务似乎没有生成触发写入事件日志的任何事件。 事件历史logging已打开。 这是我为触发器设置的脚本: <QueryList> <Query Id="0" Path="Microsoft-Windows-TaskScheduler/Operational"> <Select Path="Microsoft-Windows-TaskScheduler/Operational">*[System[(EventID=101 or EventID=103 or EventID=111 or EventID=311 or EventID=329)]] and *[EventData[Data and (Data='backup db')]]</Select> </Query> </QueryList> 我从这个post得到的ID列表: https : //mnaoumov.wordpress.com/2014/05/15/task-scheduler-event-ids/ 我怎样才能让电子邮件任务触发?

Powershell:将Registrykey所有者设置为SYSTEM用户

我必须将排除path添加到Windows Defenderregistry项。 我知道有从Windows Defender提供的Cmdlet直接将它们用于这些目的。 但不幸的是,在Windows 7和Powershell v2中,它们不可用。 所以我正在尝试构build一个手动input值到registry项的脚本。 通过在线研究,我已经编写了一个脚本,首先将所有者更改为pipe理员,然后添加该值,最后再将所有者设置为最初的所有者。 我的代码如下: 代码来启用所需的特权: param([string]$targetPath) function enable-privilege { param( ## The privilege to adjust. This set is taken from ## http://msdn.microsoft.com/en-us/library/bb530716(VS.85).aspx [ValidateSet( "SeAssignPrimaryTokenPrivilege", "SeAuditPrivilege", "SeBackupPrivilege", "SeChangeNotifyPrivilege", "SeCreateGlobalPrivilege", "SeCreatePagefilePrivilege", "SeCreatePermanentPrivilege", "SeCreateSymbolicLinkPrivilege", "SeCreateTokenPrivilege", "SeDebugPrivilege", "SeEnableDelegationPrivilege", "SeImpersonatePrivilege", "SeIncreaseBasePriorityPrivilege", "SeIncreaseQuotaPrivilege", "SeIncreaseWorkingSetPrivilege", "SeLoadDriverPrivilege", "SeLockMemoryPrivilege", "SeMachineAccountPrivilege", "SeManageVolumePrivilege", "SeProfileSingleProcessPrivilege", "SeRelabelPrivilege", "SeRemoteShutdownPrivilege", "SeRestorePrivilege", "SeSecurityPrivilege", "SeShutdownPrivilege", "SeSyncAgentPrivilege", […]

PSSession作为login用户

我试图设置一个Powershell脚本来监视在我们的一个构build服务器上运行的VirtualBox VM(即“Builder4”)。 它有时会失去连接,我已经有一个脚本(在本地服务器上)重新加载networking适配器,但我想使其完全自动化。 我有PSSession与服务器正确authentication,连接成功,我可以从服务器运行命令,做一个交互式会话(Enter-PSSession)等,但是,这是一个“新”的会议,所以我不能pipe理任何已经运行的虚拟机 服务器设置是具有单个帐户的Windows Server 2012框。 该帐户在服务器本地,而不是在公司域(“pc-name \用户”与“company.na.com \用户”),并保持login,只要服务器正在运行。 通常我们通过RemoteDesktop连接到服务器。 即使我使用相同的pc-name,用户名和凭证连接到PSSession,它似乎并没有连接到服务器上的现有login,尽pipe我唯一支持的证据是VBoxManage list runningvms返回一个空的清单。 例如,运行以下(“test.ps1”的基本内容): whoami VBoxManage list vms echo —– VBoxManage list runningvms 给出以下输出: 从远程会话 PS …> test.ps1 win-*******\jenkins "Builder1" {vm-hash-code} "Builder2" {vm-hash-code} "Builder3" {vm-hash-code} "Builder4" {vm-hash-code} "Builder5" {vm-hash-code} "Builder6" {vm-hash-code} —– PS …> 从服务器(本地) PS …> test.ps1 win-*******\jenkins "Builder1" {vm-hash-code} "Builder2" {vm-hash-code} "Builder3" […]

如何查看哪些IISconfiguration元素从默认更改?

在Windows Server 2012,2012-R2和2016(例如IIS v8.0及更高版本) 我们有一个IIS设置,多年来一直在发展。 我如何提取其“三angular洲默认IIS”,所以我们可以做一个脚本来设置其他机器相同的方式? 我知道如何在Apache和Tomcat上执行此操作(对运行的configuration文件与默认configuration进行比较)。 我如何对付IIS,并真正捕捉所有的东西? 目标不是“共享”或“导出”configuration。 目标是要知道这个IIS实例与股票IIS有什么不同,所以我们可以编写脚本。

门户上的Azure DSCvalidation错误

在使用DSC扩展在Azure门户中validation新VM时, value for the template parameter 'modulesUrl' at line '11' and column '20' is not provided的原因value for the template parameter 'modulesUrl' at line '11' and column '20' is not provided任何提示。 知道一些潜在的模板有错误是没有帮助的。 DSCconfiguration剥离到最低testing版本是 configuration WebServer { Node localhost { WindowsFeature IIS { Ensure = 'Present' Name = 'Web-Server' } WindowsFeature DotNet { Ensure = 'Present' Name […]

Cloudberry Explorer PowerShell错误

我正尝试使用Cloudberry Explorer PowerShell脚本自动将文件从Amazon S3存储拉到本地磁盘。 使用桌面应用程序,我能够手动连接并将文件转移到本地文件夹就好了。 当使用PowerShell时,我收到一个错误,指出The Remote name could not be resolved 'http' 。 下面是我的代码,我相信是正确的。 我尝试过,没有代理信息,我得到同样的错误。 我也有我的networkingpipe理员绕过代理validation的网站。 我不知道还有什么可能导致这个错误。 Add-PSSnapin CloudBerryLab.Explorer.PSSnapIn #Set Proxy info Set-CloudOption -ProxyAddress [proxy info here] -ProxyPort 8080 #Set connection to Amazon S3 account with access key and secret key $s3 = Get-CloudS3Connection -Key ***** -Secret ***** -SignatureVersion 2 -UseSSL #Set source and […]

在PowerShell Linux上缺lessWSMan提供程序(要使用远程处理)

我试图从Linux远程PowerShell到Azure上的Windows Nano服务器。 在说明中,我将远程服务器的IP添加到本地计算机的可信主机中: PS > Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value "1.2.3.4" Set-Item : Cannot find drive. A drive with the name 'WSMan' does not exist. At line:1 char:1 + Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value "1.2.3 … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (WSMan:String) [Set-Item], DriveNotFoundException + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetItemCommand 如果我忽略此消息并尝试连接,则出现错误: PS > Enter-PSSession -ComputerName "1.2.3.4" -Credential joe […]

在Windows Server上为所有用户和系统帐户设置代理

我们正在尝试为Azure部署ARM模板。 我们希望为所有用户和系统帐户设置代理。 但我们无法做到这一点。 当我们使用这个PowerShell脚本,当前用户有一个代理,但不是系统帐户。 有什么build议么? <# .Synopsis This function will set the proxy settings provided as input to the cmdlet. .Description This function will set the proxy server and (optinal) Automatic configuration script. .Parameter ProxyServer This parameter is set as the proxy for the system. Data from. This parameter is Mandatory .Example Setting proxy information […]