我很困惑,为什么我有不同的信息,我试图从中检索。 我有3台运行Hyper-V的Windows 2012服务器(G0,G1和G2)。 以下情况是从一台服务器捕获的,我用它来运行脚本并控制其他服务器。 我想要做的是获得这3台机器上的虚拟机列表: 使用PowerGUI和PowerShell ISE : PS > Get-VMHost | select name Name —- G0.nothing.com G2.nothing.com G1.nothing.com PS > Get-VMHost | Get-VM | select name Name —- VM1628856-4 VM1628856-2 VM1628856-6 VM1628856-3 VM1628856-1 VM1628856-5 使用PowerShell : PS > Get-VMHost | select name Name —- G0 PS > Get-VM Name State CPUUsage(%) MemoryAssigned(M) Uptime Status […]
我正在尝试使用Powershell在群集服务器上添加ClusteredScheduledTask(Win 2012 / R2) Technet示例代码给出错误: #canned exampled from http://technet.microsoft.com/en-us/library/jj649815.aspx $Action01 = New-ScheduledTaskAction -Execute Notepad $Action02 = New-ScheduledTaskAction -Execute Calc Set-ClusteredScheduledTask -TaskName "Task03" -Action $Action01,$Action02 错误: Set-ClusteredScheduledTask : Incorrect function. At I:\Scripts\TaskSchedulerSetupJobs\TestWebSampleCode.ps1:4 char:1 + Set-ClusteredScheduledTask -TaskName "Task03" -Action $Action01,$Action02 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (PS_ClusteredScheduledTask:Root/Microsoft/…edScheduledTask) [Set-ClusteredScheduledTask], CimException + FullyQualifiedErrorId : HRESULT 0x80070001,Set-ClusteredScheduledTask 补充:正如KrisFR指出的那样,我真的打算做一个Register,而不是Set,但是我仍然得到相同的基本错误: #canned exampled […]
我在使用powershell显示帐户的密码过期之前,我重置它在工作中。 但是我所看到的全球GP是180天,而且有一些员工有90天的账户。 这些其他政策在哪里设置,这样我可以看到他们有什么? 我在powershell中查询msDS-UserPasswordExpiryTimeComputed 。 编辑:我跑gpresult /hc:\temp\gpresult.html ,只能find以下结果 Account Policies/Password Policyhide Policy Setting Winning GPO Enforce password history 24 passwords remembered Default Domain Policy Maximum password age 180 days Default Domain Policy Minimum password age 0 days Default Domain Policy Minimum password length 6 characters Default Domain Policy Password must meet complexity requirements Disabled Default […]
我想find一个PowerShell脚本来检索给定的计算机或用户的SCCM集合。 我知道这可以通过SCCM查询来实现,但是我想使用PowerShell函数来实现。 该脚本应与SCCM 2007和SCCM 2012一起使用。
使用GUI添加angular色和function时,还有一些额外的步骤可以让您进行一些额外的configuration。 例如,安装WSUS时,有几个标有“angular色服务”和“内容”的步骤,可让您select要使用的数据库并为此数据库设置位置。 (下图) 但是让我们说我想通过PowerShell来安装它。 我会input以下内容: Import-Module servermanager Install-WindowsFeature -Name UpdateServices -IncludeAllSubFeature -IncludeManagementTools 然而,这并不能让我指定我想放置数据库的位置,就像GUI一样。 有没有什么命令可以让我从powershell进一步configurationWSUS? 谢谢。
目标 :为OU中的每个用户创build一个for或foreach循环来执行一些代码(在这种情况下,只是打印x)。 我使用PowerShell 2.0和ActiveDirectory模块。 到目前为止 :这是我的(见下文)。 它只是打印出每个用户的X. 但它不是我想要的,而是我认为它可能是为了每一行。 所以我得到了6个X的'名字','—-','test1','test2',空格,空格。 $pool = Get-ADUser -Filter * -SearchScope Subtree -SearchBase "OU=Test,OU=Users,OU=jack,DC=Corp,DC=jill,DC=com" -Properties name | FT name foreach ($user in $pool ) { write-host "x"} $pool 结果 ,SPACE将以句点(。)表示: x x x x x x name —- test1 test2 . . 我不知道为什么这样做。 如果您有更好的方法来处理这个问题,我会很高兴听到这个消息。
所以我试图按计划运行PowerShell脚本。 每天早上六点,重复一天中的每一个小时。 这是脚本本身: Get-Content C:\Users\administrator\Desktop\users.txt | ForEach-Object { Set-AdUser -Identity $_ -LogOnWorkstations $null } 现在,当我自己执行脚本时,脚本完美无瑕。 但是好像这个脚本在执行的时候不能正常运行。 我的想法是,执行策略不断询问它是否安全地运行脚本,然后再运行它。 如果其他人同意这可能是脚本无法自行启动的原因,请围绕这个障碍提供一个解决scheme吗?
我需要更改服务帐户的instanceType属性。 如果我尝试从Active Directory用户和计算机控制台中更改它,它会变灰,如果我尝试通过使用Set-Aduser的PowerShell更改它,我会得到“该属性不能被修改,因为它是由系统拥有”。 任何人都有我如何更改instanceType属性从4到0的任何ideea?
该项目将自动创build虚拟机。 该服务器是Windows Hyper-V免费2016年。继博客文章https://www.starwindsoftware.com/blog/automate-the-hyper-v-virtual-machine-deployment-with-powershell我写了脚本创build虚拟机一个特定的用户(它绑定到用户的电子邮件): $User = Read-Host -Prompt 'Input the user email' $VMName = "sr-si-01_$User" # Automatic Start Action (Nothing = 0, Start =1, StartifRunning = 2) $AutoStartAction = 0 # In second $AutoStartDelay = 10 # Automatic Start Action (TurnOff = 0, Save =1, Shutdown = 2) $AutoStopAction = 2 ###### Hardware Configuration ###### # […]
我需要recursion地获取一个目录的大小。 我每个月都要这样做。 我想要做一个PowerShell脚本来做到这一点。