Articles of PowerShell

是否有可能禁用msiexec帮助GUI?

我使用powershell脚本实现了自动检索和安装指定的.msi包,但是如果命令被调用时出现语法错误,msiexec将无限期地等待其帮助显示中的确定单击,尽pipe存在/ quiet和/或/ passive 。 目前我正在调用它: (start-process -FilePath "msiexec" -ArgumentList "/i <path_to_package> /quiet /passive" -PassThru -Wait).ExitCode 有没有办法禁用msiexec帮助显示?

如何从PowerShell中的所有网站列出IIS中的虚拟目录

我碰到了一个完整的障碍,不知道如何打印IIS 8每个网站的虚拟目录。 我不断检索应用程序,并清空空参数错误,只是找不到一个方法来获取虚拟目录列出。 我需要以下数据列出虚拟目录: 物理path 应用程序池关联 网站名称 证书 下面是我一直在使用和搞乱的代码: *See revised code below* 我也使用Appcmd.exe命令尝试列出虚拟目录: C:\Windows\System32\inetsrv\appcmd.exe LIST VDIRS 但是我仍然没有得到我需要的输出。 任何或任何帮助将不胜感激! 谢谢! 编辑# – – – – – – – – – – – – – – – – – – – – – – – – ———————- 得到我的虚拟目录列出了通过注释了几行,但它只打印出名称和: 物理path 应用程序池关联 网站名称 证书 对我来说还是未知的,下面是修改后的代码: Import-Module WebAdministration $Websites […]

如何导出Office 365中的完整SMTP日志

在Office 365中,是否可以导出SMTP日志? 也许在PowerShell或任何其他方式。 我的目标是全面了解从特定域发送到特定域的所有邮件。

“Get-AdComputer -filter”在查找Vista客户端时不返回任何内容

为什么Get-Computers -OperatingSystem "Windows VistaT Business"不能返回任何东西? 它适用于所有其他操作系统types。 Function Get-Computers { Param($OperatingSystem) Get-AdComputer -Filter 'OperatingSystem -eq ${OperatingSystem}' -SearchBase "OU=Departement,DC=contoso,DC=com" } #Get-Computers -OperatingSystem "Windows Server 2012 R2 Standard" #Get-Computers -OperatingSystem "Windows Server 2008 R2 Standard" #Get-Computers -OperatingSystem "Windows 7 Professional" Get-Computers -OperatingSystem "Windows VistaT Business" 我明确确实有Vista客户端和string寻找是Windows VistaT Business 。 PS C:\> (get-adcomputer ClientA -Properties *).OperatingSystem Windows 7 Professional […]

Powershell:找不到匹配的参数

我是Powershell世界的新手。 下面是我的第一个脚本 $sServer = "Fully.Qualified.Computer.Name" $os = Get-WmiObject -class Win32_OperatingSystem -computername $sServer $object = New-Object –TypeNamePSObject $object | Add-Member –MemberTypeNoteProperty –Name OSBuild –Value $os.BuildNumber $object | Add-Member –MemberTypeNoteProperty –Name OSVersion –Value $os.Version $object | Add-Member –MemberTypeNoteProperty –Name BIOSSerial –Value $bios.SerialNumber Write-Output $object 当我在PowershellISE中运行此脚本时,出现以下错误。 New-Object : A parameter cannot be found that matches parameter name 'TypeNamePSObject'. […]

我如何使用PowerShell脚本来更改SQL Server别名?

我有一台x64机器,经常需要在SQL Server客户端networking实用程序(cliconfig)中更改registry的x64和x86端的大约10个别名。 有没有办法我可以用PowerShell脚本来做到这一点?

Invoke-Restmethod在PS 4.0中打破了脚本

我有一个Powershell脚本,使用PowerShell 3.0中的Invoke-RestMethod。 但是,我升级到PowerShell 4.0来修复PowerShell 3中的错误。当我这样做,我的脚本似乎已经停止工作。 $username = "Administrator" $password = "PASSWORD" $uri = "https://10.0.0.18/vmrest/users" $dictionary = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f$username,$password))) $dictionary.Add("Authorization",$base64AuthInfo) Invoke-RestMethod -Uri $uri -Method GET -Headers $dictionary -Verbose 当我打开详细的开关,它给了我这个回应 VERBOSE: GET https://192.168.1.18/vmrest/users with 0-byte payload VERBOSE: received -1-byte response of content type 我也尝试指定请求的内容types,但没有骰子$dictionary.Add("Accept","application/json") $dictionary.Add("Connection", "keep_alive")

如何更改我的默认PowerShellconfiguration文件/数字签名我的$configuration文件?

我试图创build一个我的PowerShell环境的终极设置。 我用一堆语句创build了“Microsoft.PowerShell_profiles.ps1”来设置我的默认configuration文件。 当我启动PowerShell会话时,我得到: File C:\Documents and Settings\xxx\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded. The file C:\Documents and Settings\xxx\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 is not digitally signed. The script will not execute on the system.

你在哪里共享或find有用的PowerShell,Bash,批处理,VBS,脚本?

我刚刚写了一个快速的小PowerShell脚本,使我的生活更容易,我面临的任务。 我认为把它放在互联网上是很好的,别人也可能会觉得它有用。 麻烦的是,为我的小脚本打开一个新的CodePlex或SourceForge“项目”感觉像是矫枉过正。 是否有类似的网站共享或开放源代码脚本?

使用Powershellrecursion更改所有者?

我试图用PowerShell来recursion地改变一个文件夹的所有者。 我基本上使用这个代码: $acct1 = New-Object System.Security.Principal.NTAccount('DOMAIN\Enterprise Admins') $profilefolder = Get-Item MyFolder $acl1 = $profilefolder.GetAccessControl() $acl1.SetOwner($acct1) set-acl -aclobject $acl1 -path MyFolder 这将改变第一级的所有权,但不会改变任何子文件夹或文件。 有没有办法将范围扩展到MyFolder所有内容?