Quantcast
Channel: Windows PowerShell forum
Viewing all 21975 articles
Browse latest View live

PowerShell Script - Remove writing permissions for certain groups in a folder structure

$
0
0

Hello everyone!

We would like to remove the writing permissions for all security groups that contain normal ad users in our archive folder structure.

I would like to explain the situation a bit more detailed first:

There is an archive folder. It consists of many different subfolders. Per subfolder there are two security groups for example called:

1.) EU TEST Z_TESTFOLDER_R (members which are allowed to read)

2.) EU TEST Z_TESTFOLDER_RW (members which are allowed to write)

Sometimes those rights don't get inherited by a subfolder because some users in the before mentioned RW group are not allowed to write on that specifc subfolder. If that is the case there are two new security groups:

1.) EU TEST Z_TESTFOLDER_SUBFOLDER_R

2.) EU TEST Z_TESTFOLDER_SUBFOLDER_RW

So my goal is it basically to remove the write permissions of every single RW security group in the whole archive folder structure...

I am looking for a PowerShell script that scans my whole archive (which means every subfolder as well as every file) and then removes the write permissions for every security group which ends in "RW".

I would be very helpful if someone could assist me in that matter and give me some basic approach for the script.

Please let me know if my information was not precise enough in order that i can provide it to you more detailed.

Thank you very much.

Best regards,

Dario


How can I conditionally change text output?

$
0
0

Trying to modify text output, inline, based on a True|False condition

i.e.:

"the condition is: <condition>" should become

"the condition is: Yup" or "the condition is: Badboy"

I'm trying to use some inline code.  for example: "{if ($condition) {"Yup"} else {"Nope"}}" but can't seem to get it to work.

cls
$condition=$true
if ($condition) {"Yup"} else {"Nope"}  #this actually provides the proper output, but I can't seem to integrate it to the complete string output.

#the following line does not provide the proper result. 

"Test string " + ({if ($condition) {"Yup"} else {"Nope"}}) +"."

Running installation from mapped drive using powershell

$
0
0

Hi,

i am trying to install AV using powershell but i don't know where am i failing. Not very proficient with powershell so it could be beginner mistake :).

This is script:

$s = New-PSSession -ComputerName "testsrv" Enter-PSSession -Id $s.Id Set-ExecutionPolicy ByPass -Scope CurrentUser Invoke-Command -Session $s -ScriptBlock {New-PSDrive –Name "P" –PSProvider FileSystem –Root "\\nas\NASSHARE"} Invoke-Command -Session $s -ScriptBlock {&"P:\SymantecAV_install_package\SymRedistributable.exe -silent"}

This is error:

The term 'P:\SymantecAV_install_package\SymRedistributable.exe -silent' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was in
cluded, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (P:\SymantecAV_i...ble.exe -silent:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I tried connecting to P drive using powershell on that machine and i can browse to that location. It's powershell v2 (win 2008r2).

Password set to expire script

$
0
0

There is a lot of different on this powershell stuff, but unable to get this working

What I search for is a way to create a file, where the usernames are listed, where password will expire within 5 days

I have found the following - it creates a file, but nothing is inside the file. I am a newbie to powershell, so just trying to look what there is on the internet, but not yet found anything that is working

$a = (get-date).AddDays(7) ; Search-ADAccount -AccountExpiring  -TimeSpan "7" | Select-Object SamAccountName,AccountExpirationDate | Sort-Object AccountExpirationDate | Where-Object  {$_.AccountExpirationDate -like $a } | Export-Csv 7_days.csv

Forms in PowerShell: create a "Select All" checkbox in a CheckedListBox

$
0
0

Hello all,

I have the following code that generates a checkedlistbox:

cls
import-module ActiveDirectory

Add-Type -AssemblyName System.Windows.Forms

[void][system.reflection.assembly]::LoadWithPartialName("System.Drawing")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$objForm = New-Object System.Windows.Forms.Form

$objForm.Text = "Test"
$objForm.Size = New-Object System.Drawing.Size(500,200)
$objForm.StartPosition = "CenterScreen"

$CheckedListBox = New-Object System.Windows.Forms.CheckedListBox
$CheckedListBox.Location = New-Object System.Drawing.Size(20,20)
$CheckedListBox.size = New-Object System.Drawing.Size(300,100) #THIS FIELD AND OTHERS HERE NEED TO BE DYNAMIC BASED ON FILE LENGTHS!
$CheckedListBox.CheckOnClick = $true #so we only have to click once to check a box
$CheckedListBox.Items.Add("Select All")
$CheckedListBox.Items.AddRange(1..10)
$CheckedListBox.ClearSelected()
$objForm.Controls.Add($CheckedListBox)

#put form in front of other windows
$objForm.TopMost = $True

#display the form
$DisplayForm = $objForm.ShowDialog()

I'm trying to get it to when the "Select All" checkbox is checked, the form updates all the other checkboxes to being checked while the form is still up (so the user can see they're all checked). I've seen the following post but I can't quite follow it:

http://social.msdn.microsoft.com/Forums/windows/en-US/4c622dbc-71db-4dbc-af3e-9ed793830ef2/checkedlistbox-selct-all-items?forum=winforms

Anyone have any idea how to make a "select all" checkbox?

What is the value returned by read-host when the cancel button is pressed

$
0
0

I though the value would be $null, but is not. What value is returned when I click cancel in the read-host windows prompt. It gives me an error when i click on cancel.

thanks

Forms in PowerShell: Enable Button based on Radio Button click

$
0
0

Hello all,

The following is a basic form with 3 radio buttons:

cls
import-module ActiveDirectory

[void][system.reflection.assembly]::LoadWithPartialName("System.Drawing")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$objForm = New-Object System.Windows.Forms.Form

$objForm.Text = "Test"
$objForm.Size = New-Object System.Drawing.Size(400,200)
$objForm.StartPosition = "CenterScreen"

$RadioButton1 = New-Object System.Windows.Forms.RadioButton
$RadioButton1.Location = New-Object System.Drawing.Size(10,10)
$RadioButton1.Size = New-Object System.Drawing.Size(100,20)
$RadioButton1.Checked = $false
$RadioButton1.text = "Button1"
$objForm.controls.Add($RadioButton1)

$RadioButton2 = New-Object System.Windows.Forms.RadioButton
$RadioButton2.Location = New-Object System.Drawing.Size(10,50)
$RadioButton2.Size = New-Object System.Drawing.Size(100,20)
$RadioButton2.Checked = $false
$RadioButton2.text = "Button2"
$objForm.controls.Add($RadioButton2)

$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(10,120)
$OKButton.Size = New-Object System.Drawing.Size(150,30)
$OKButton.Text = "OK"
$OKButton.Enabled = $false
$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$objForm.Controls.Add($OKButton)
$objForm.AcceptButton = $OKButton

$objForm.TopMost = $True

$Form = $objForm.ShowDialog()

What I want is for the "OK" button to become enabled when a radio button is checked. How can I do this?

Forms in PowerShell: Update form based on script progress

$
0
0

Hello all,

For lack of a better post title, what I have is a simple script that loops through files in a directory and checks them for stuff. What I'd like to do is, while my script is checking the files, display a form with only one single-line field in it, and that field updates with the current file variable the script is checking. This would kind of be like when you're installing a program, and in the installation window above the progress bar it has a single-line field where it lists each file while it's currently installing. I'd like something similar, but I don't need the progress bar. I'd like to just have a single form and have only this single "file" field change, but I worry that I'll have to redisplay the entire form in some kind of "loop" every time I want the field to change. I'd like to display the form once and only have the field change.

Has anyone ever made a form like this, or know of a way I can accomplish this?



Delete Scheduled Tasks using PowerShell

$
0
0

Been trying to get this work, but having no luck.  

I need to delete the Adobe Flash Player Updater Scheduled Task after I install Adobe Flash.  

In my cmd line batch script I used the command:

SCHTASKS.exe /DELETE /TN "Adobe Flash Player Updater"


Cannot figure for the life of me how to get this to run in powerShell without having to install additional cmdlets, etc.  I tried 

  $Path = "C:\Windows\System32\schtasks.exe"
    $ARGS =  "/DELETE /TN Adobe Flash Player Updater"
    Start-Process -FilePath $Path -ArgumentList $ARGS -Verb Runas -Wait 

but that did not work.  

Anyone have any simple ideas?

Thanks.  


Matt Dillon

Forms in PowerShell: putting write-progress onto a pre-made form

$
0
0

Hello all,

What I'm wanting to do is use the "Write-Progress" cmdlet and put it onto a form that I've made, instead of having a separate dialogue box for it. Is this possible? Here is the (very simple) form:

[void][system.reflection.assembly]::LoadWithPartialName("System.Drawing")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$objForm = New-Object System.Windows.Forms.Form

$objForm.Text = "Test" 
$objForm.Size = New-Object System.Drawing.Size(700,300) 
$objForm.StartPosition = "CenterScreen"

$Form = $objForm.ShowDialog()

PS1 command to generate IP Configuration for all Servers

$
0
0
Any PS command which can be used to generate IP Details and hostname(Server IP, Prefered and Alterate DNS IP, Hostname) assigned to servers in a domain. Or generate the same for a list of servers?

Parsing html for a value on a page?

$
0
0

I'm wanting to use Powershell to extra information from a particular page.  It's really somewhat simple but not sure how to do in Powershell.

$r = Invoke-WebRequest  <some url>

that part works.  I can actually print out $r and it has the contents of the page, html tags, everything.

Now I want to search for a particular item:

<span class="view-count-label">100</a>

I'd like to be able to tell what the number is that is contained inside that span; in this case, 100.

Adding a Local User to the Administrators group using Powershell

$
0
0

Windows 2008 R2, SP1 Standalone server, NO AD

# ------------------------------------------------------------------------
# NAME: AddLocalUser.ps1
# AUTHOR:
# DATE: 12/19/2012
#
# COMMENTS: This script adds local users on a local comptuer.
#
# ------------------------------------------------------------------------
[ADSI]$Server="WinNT://."
$QAUser=$Server.Create("User","Gerry")
$QAUser.Put("FullName","Gerry Smith")
$QAUser.Put("Description","Quality Assurance Analyst")
$QAUser.SetPassword("Password")
$PwordFlag=$QAUser.UserFlags.value -bor 0x10000
$QAUser.Put("UserFlags",$PwordFlag)
$QAUser.SetInfo()
Start-Sleep -s 5
$Group=[ADSI]"WinNT://WORKGROUP/./Administrators,Group"
$Group.Add($QAUser.path)

Above is a script I found to add a user to the system which works great until It gets to the part where you need to add the user to a group (last two lines), then I get the following:

Exception calling "Add" with "1" argument(s): "A member could not be added to or removed from the local group because the member does not exist."

At D:\Scripts\PowerShell\Commands\AddLocalUser.ps1:19 char:11
+ $Group.Add <<<< ($QAUser.path)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvokeTI

I havent really seen a solution to this problem on the Internet, any suggestions? Below is some environment info.

Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\Administrator> [ADSI]$Server="WinNT://."
PS C:\Users\Administrator> $Server | select *


OperatingSystem        : {Windows NT}
OperatingSystemVersion : {6.1}
Owner                  : {Company.}
Division               : {Company.}
ProcessorCount         : {Multiprocessor Free}
Processor              : {Intel64 Family 6 Model 15 Stepping 6}
Name                   : {.}
AuthenticationType     : Secure
Children               : {Administrator, ASPNET, EP_User, FSS_User...}
Guid                   : {DA438DC0-1E71-11CF-B1F3-02608C9E7553}
ObjectSecurity         :
NativeGuid             : {DA438DC0-1E71-11CF-B1F3-02608C9E7553}
NativeObject           : System.__ComObject
Parent                 : WinNT://WORKGROUP
Password               :
Path                   : WinNT://.
Properties             : {OperatingSystem, OperatingSystemVersion, Owner, Division...}
SchemaClassName        : Computer
SchemaEntry            : System.DirectoryServices.DirectoryEntry
UsePropertyCache       : True
Username               :
Options                :
Site                   :
Container              :

 

PS C:\Users\Administrator> $QAUser
PS C:\Users\Administrator> $QAUser=$Server.Create("User","Gerry")
PS C:\Users\Administrator> $QAUser

distinguishedName :
Path              : WinNT://WORKGROUP/./Gerry

Thanks, Gerry

Error when starting Power shell on Windows 2112 r2

$
0
0

Using Windows 2012 r2 and trying to start Power Shell and it  keeps shutting down with will advise once we find a solution to error.

In the event log I get two errors.  How can I fix this error?

Thanks

Event error #1

- System
  - Provider
   [ Name]  .NET Runtime
   - EventID 1023
   [ Qualifiers]  0
   Level 2
    Task 0
    Keywords 0x80000000000000
   - TimeCreated
   [ SystemTime]  2014-08-25T19:39:25.000000000Z
   EventRecordID 12193
   Channel Application
    Computer webserver
    Security
 - EventData
   Application: powershell.exe Framework Version: v4.0.30319 Description: The process was terminated due to an internal error in the .NET Runtime at IP 00007FFAAB411DF1 (00007FFAAB210000) with exit code 80131506. 

**********************************************

Event error # 2

- System
  - Provider
   [ Name]  Application Error
   - EventID 1000
   [ Qualifiers]  0
    Level 2
    Task 100
    Keywords 0x80000000000000
   - TimeCreated
   [ SystemTime]  2014-08-25T19:39:25.000000000Z
    EventRecordID 12194
    Channel Application
    Computer webserver
    Security
- EventData
   powershell.exe
   6.3.9600.16384
   5215ef23
   clr.dll
   4.0.30319.34014
   52e0b86c
   c0000005
   0000000000201df1
   dec
   01cfc09c4202d5d8
   C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
   C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
   84e53e8d-2c8f-11e4-80f6-00155d140b06

 

cjb

Command executes when typed, but not when generated ?

$
0
0

I made a powershell script to generate a ruby command. The command takes forever to execute 
when generated and run by the script. However, when its typed, it runs quickly and gets
the job done. Script logic is :

$dat1 = one ruby command |Out-String# $dat1  will contain the value - rake drive:unit_tests:load_data
$dat2 ="  parameters here"
$dat3 = $dat1 + $dat2
$dat3 = $ExecutionContext.InvokeCommand.NewScriptBlock($dat3)& $dat3

Can someone please help me to figure out why this is happening and how to resolve this ?


Value returned by read-host when CANCEL button is pressed

$
0
0

According to this

http://social.technet.microsoft.com/Forums/windowsserver/en-US/0d8b981e-7757-4e72-a6f3-3eaa984d977e/what-is-the-value-returned-by-readhost-when-the-cancel-button-is-pressed?forum=winserverpowershell

the value that read-host returns when CANCEL button is pressed is $NULL


PS C:\Windows\System32\WindowsPowerShell\v1.0> $a = read-host "please cancel me"

____________________________________________________________________________
PS C:\Windows\System32\WindowsPowerShell\v1.0> if ($A -eq $null) {'null'}
null

I have a function that prompts users for multiple pairs of passwords, and if the user presses CANCEL the function should exit

    if (($password -eq $NULL) -or ($confirmpassword -eq $NULL)){
        return
    }

Unfortunately, the script exits (because "hello world" is never printed). Is there something I am missing?

function createPwdFiles(){ $stamp = $(get-date -f HH_mm_ss) $password = Read-Host "Enter password" -AsSecureString $confirmpassword = Read-Host "Confirm password" -AsSecureString if (($password -eq $NULL) -or ($confirmpassword -eq $NULL)){ return } $pwd1_text = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($password)) $pwd2_text = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($confirmpassword)) if($pwd1_text -ne $pwd2_text) { [System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”) | Out-Null [Windows.Forms.MessageBox]::Show(“Passwords don't match, please try again”, “Passwords don't match”, [Windows.Forms.MessageBoxButtons]::OK, [Windows.Forms.MessageBoxIcon]::Information) | Out-Null } else{ $password | convertfrom-securestring | out-file $pwd_path\$stamp.txt Add-Content $cred_path\pwd_list.txt $pwd_path\$stamp.txt } } $intAnswer = 6 $a = new-object -comobject wscript.shell do{ createPwdFiles $intAnswer = $a.popup("Do you want add another password?", ` 0,"Password",4) }while ($intAnswer -eq 6)

write-output "hello world"

Forms in PowerShell: clear checkedlistbox items when "select all" is deselected

$
0
0

Hello all,

I recently got help to add a "select all" checkbox to my checkedlistbox, and it works great. However, I'd like to have it also work where, when the "select all" checkbox is consequently unchecked, it clears all the checkboxes. Is this easy to do, or would it be easier to just have an "unselect all" checkbox? Code is as follows:

[void][system.reflection.assembly]::LoadWithPartialName("System.Drawing")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$objForm = New-Object System.Windows.Forms.Form

$objForm.Text = "Test" 
$objForm.Size = New-Object System.Drawing.Size(700,300) 
$objForm.StartPosition = "CenterScreen"

$CheckedListBox = New-Object System.Windows.Forms.CheckedListBox
$CheckedListBox.Location = New-Object System.Drawing.Size(20,20)
$CheckedListBox.size = New-Object System.Drawing.Size(300,100)
$CheckedListBox.CheckOnClick = $true
$CheckedListBox.Items.Add("Select All") > $null
$CheckedListBox.Items.AddRange(1..20)
$CheckedListBox.ClearSelected()
$CheckedListBox.Add_click({
    If($this.selecteditem -eq 'Select All'){
        For($i=1;$i -lt $CheckedListBox.Items.Count; $i++){
            $CheckedListBox.SetItemChecked($i,$true)
        }
    }
})
$objForm.Controls.Add($CheckedListBox)

$Form = $objForm.ShowDialog()



Automatically generate a response to a powershell command?

$
0
0

I am executing a powershell script i.e commands in a ps1 file. To run any powershell script on a system, you have to first run Set-ExecutionPolicy RemoteSigned and then ENTER y manually. Only after that, you can run ps scripts. Is there a way I can automatically enter y along with the command to enable powershell scripts ?

Demo:

PS C:\Windows\system32> Set-ExecutionPolicy RemoteSigned

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. 
Changing the execution policy might expose you to the security risks described 
in the about_Execution_Policies help topic. Do you want to change the execution 
policy? [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):

Backup all GPOs rights needed ?

$
0
0

Hi,

I would like to backup all my GPOs (through for example PowerShell cmdlet).

I would like to know which rights I need to do that ? Is there a builtin account for that ? (I dont think a domain user account can do this as some GPOs can have restricted access)

Thank you.

SMS_PowerConfigs

$
0
0

Hi everybody

Is there anybody who can tell me what im doing wrong?

Im trying to enable the default power management setting on a collection in sccm 2012 r2.

All im getting is:

Exception calling "Put" with "0" argument(s): "Generic failure "
At line:165 char:1+ $Collsetting.Put()+ ~~~~~~~~~~~~~~~~~~+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException+ FullyQualifiedErrorId : DotNetMethodException

My Code:

$SiteCode = 'P01'
$Server = 'sccmp01'
$CollectionID = 'P010000A'

cls
[wmi]$Collsetting = Get-WmiObject -Class SMS_CollectionSettings -Namespace root\sms\site_$SiteCode -Filter "CollectionID='$CollectionID'"
$Collsetting = $Collsetting.__PATH

$NonPeakPowerPlan = '<?xml version="1.0" encoding="utf-16"?><PowerScheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" GUID="22B698A7-B734-4107-B5E0-
4BD16375F5C2" Name="Balanced (ConfigMgr)" Description="Automatically balances performance with energy consumption on capable hardware (ConfigM
gr)"><PowerSettings><PowerSetting><GUID>3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e</GUID><CurrentACPowerSettingIndex>1200</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>600</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>29f6c1db-86da-48c5-9fdb-f2b67b1f44da</GUID><CurrentACPowerSettingIndex>3600</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>900</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>0e796bdb-100d-47d6-a2d5-f7d2daa51f51</GUID><CurrentACPowerSettingIndex>1</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>1</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>7648efa3-dd9c-4e3e-b566-50f929386280</GUID><CurrentACPowerSettingIndex>1</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>1</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>a7066653-8d6c-40a8-910e-a1f54b84c7e5</GUID><CurrentACPowerSettingIndex>0</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>0</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>96996bc0-ad50-47ec-923b-6f41874dd9eb</GUID><CurrentACPowerSettingIndex>1</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>1</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>5ca83367-6e45-459f-a27b-476b1d01c936</GUID><CurrentACPowerSettingIndex>1</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>1</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>6738e2c4-e8a5-4a42-b16a-e040e769756e</GUID><CurrentACPowerSettingIndex>1200</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>300</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>9d7815a6-7ee4-497e-8888-515a05f02364</GUID><CurrentACPowerSettingIndex>0</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>0</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>d8742dcb-3e6a-4b3c-b3fe-374623cdcf06</GUID><CurrentACPowerSettingIndex>0</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>0</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>637ea02f-bbcb-4015-8e2c-a1c7b9c0b546</GUID><CurrentACPowerSettingIndex>0</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>2</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>81cd32e0-7833-44f3-8737-7081f38d1f70</GUID><CurrentACPowerSettingIndex>0</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>0</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>bd3b718a-0680-4d9d-8ab2-e1d2b4ac806d</GUID><CurrentACPowerSettingIndex>1</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>1</CurrentDCPowerSettingIndex></PowerSetting></PowerSettings></PowerScheme>'

$PeakPowerPlan = '<?xml version="1.0" encoding="utf-16"?><PowerScheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" GUID="db310065-829b-4671-9647-
2261c00e86ef" Name="Customized Peak (ConfigMgr)" Description="Description for Customized Peak (ConfigMgr)"><PowerSettings><PowerSetting><GUID>3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e</GUID><CurrentACPowerSettingIndex>1200</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>660</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>29f6c1db-86da-48c5-9fdb-f2b67b1f44da</GUID><CurrentACPowerSettingIndex>3600</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>900</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>0e796bdb-100d-47d6-a2d5-f7d2daa51f51</GUID><CurrentACPowerSettingIndex>1</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>1</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>7648efa3-dd9c-4e3e-b566-50f929386280</GUID><CurrentACPowerSettingIndex>1</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>1</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>a7066653-8d6c-40a8-910e-a1f54b84c7e5</GUID><CurrentACPowerSettingIndex>0</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>0</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>96996bc0-ad50-47ec-923b-6f41874dd9eb</GUID><CurrentACPowerSettingIndex>1</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>1</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>5ca83367-6e45-459f-a27b-476b1d01c936</GUID><CurrentACPowerSettingIndex>1</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>1</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>6738e2c4-e8a5-4a42-b16a-e040e769756e</GUID><CurrentACPowerSettingIndex>1200</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>300</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>9d7815a6-7ee4-497e-8888-515a05f02364</GUID><CurrentACPowerSettingIndex>0</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>0</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>d8742dcb-3e6a-4b3c-b3fe-374623cdcf06</GUID><CurrentACPowerSettingIndex>0</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>0</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>637ea02f-bbcb-4015-8e2c-a1c7b9c0b546</GUID><CurrentACPowerSettingIndex>0</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>2</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>81cd32e0-7833-44f3-8737-7081f38d1f70</GUID><CurrentACPowerSettingIndex>0</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>0</CurrentDCPowerSettingIndex></PowerSetting><PowerSetting><GUID>bd3b718a-0680-4d9d-8ab2-e1d2b4ac806d</GUID><CurrentACPowerSettingIndex>1</CurrentACPowerSettingIndex><CurrentDCPowerSettingIndex>1</CurrentDCPowerSettingIndex></PowerSetting></PowerSettings></PowerScheme>'

$Collsetting.Get()

$PowerConfig = ([WMIClass] "\\$Server\root\SMS\site_$($SiteCode):SMS_PowerConfig").CreateInstance()
$PowerConfig.ConfigID = $CollectionID
$PowerConfig.DurationInSec = 28800
$PowerConfig.NonPeakPowerPlan = $NonPeakPowerPlan
$PowerConfig.PeakPowerPlan = $PeakPowerPlan
$PowerConfig.PeakStartTimeHoursMin = "09:00"
$PowerConfig.WakeUpTimeHoursMin = ""

$Collsetting.PowerConfigs += $PowerConfig.psobject.BaseObject
$Collsetting.Put()


wmmayms

Viewing all 21975 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>