So let's look at some basic management tasks that can be accomplished with PowerShell.
So let's start with creating, renaming and deleting and also counting GPOs.
So to create a GPO, it's really simple.
You just type new GPO, give it a name and you're good.
Now for renaming a GPO, you just use the renamed GPO can let you give it the existing name using the
name parameter and the target name, meaning the name you want to rename it to.
In this case, marketing lock down policy and you're good to go.
It makes the change.
I also want to note that the GPIO names in this case are not case sensitive.
So you can use lower or upper or any combination as long as it matches the case in sensitive name value.
You're good to go.
So don't worry about either GPO name, case or even parameter case.
I, I try to capitalized my parameters here, but I haven't done it universally and it actually doesn't
affect the behavior one bit.
So to delete a GPO, you just call the remove GPO, complete with the name of the GPO.
And then finally, if I wanted to get a count of all GPOs in my domain, I can simply type get GPO,
I'll put that in parentheses, and that acts as an an expression and then get the count property on
the result of that.
So what that's telling the Collette to do is go get all the GPOs and I don't really need to see that
big display of each GPO in detail.
I just need to know how many there are.
And that works just fine and gets you quickly gets you to account for all GPOs in the domain.
Now to modify permissions or delegation on a GPO, it's a little more complicated, but not too bad
to retrieve the permissions.
You can just type, get permission, give it the name of the GPO.
And if there's a particular permission you're interested in, you would have to use the target name,
which is the group or username that you're interested in the permission on.
Or you can use the all parameter.
It will return all the permissions on the GPO.
If I wanted to say add the sales admins group with edit rights to a particular GPO, I can use set GP
permission.
I used the name parameter to specify the GPO I'm interested in.
I set the permission level, which is a parameter that has a number of possible values, in this case
a GPO edit.
The target name is the group that I'm interested in, and the target type is the thing that it is.
So it could be a group, a computer or a user as the possible values.
Now, if I wanted to remove that sales admin group.
I could go in and set the permissions for that same GPL with the permission level of none for that group
which it with the target type of group.
So pretty much the same command.
The only difference is that permission level parameter goes from GPIO edit to none.
So now for linking GPOs.
It's really simple called a new peeling parameter.
Or I'm sorry, complete.
Give the name of the GPO.
You wanted a link.
The target parameter takes the distinguished name of the container.
It could be a domain, a site or an IOU.
In this case, I'm linking under the users O.U.
Under the marketing or you in the R three test data held domain.
I have to tell it that I want the link to be enabled and I have to give it in order.
Remember you can have multiple GPOs linked on a particular container like an o u, so you have to tell
it in what order you want this link to appear.
So in this case I'm going to make it the very first link in the order, the highest priority to set
that same link to enforced.
I can use the set up link parameter or I'm sorry, complete with the name of the GPO, the target EU,
and then the enforced parameter set to yes.
And then to remove that link all together.
All I have to do is specify the GPO name and the target DNA for backing up, restoring or importing
a GPO.
Back up is really easy.
Give it the name of the complete backup GPO.
Name of the GPO.
You want to backup the path where your backup files are located?
A comment which is optional.
And you're good to go.
It'll create that backup.
Now to restore the GPO, it's a little more a little bit more confusing.
You have to use the restored GPO come.
Let you give it a backup ID, which is not the name of the or not the idea of the GPO, not the grid
of the GPO.
It's the grid of the folder that gets created in the backup folder when you created that backup in the
first place.
And I'll show you that in a little bit.
And then the path is the path to where the backup files reside.
Now, to import a backup into a new GPO.
So this in this case, I've got a backup, that same backup.
I want to use it this time.
I want to create a new GPO called Imported Policy.
And the import chocolate gives me the option of specifying the backup I.D. the path where the backup
resides, the target name of the GPO.
In this case, it's a new GPO.
So I'm going to use the Create as needed parameter to create that GPO before it actually does the import.
If I didn't have that parameter in there, it would look for an existing GPO name called Imported Policy
and import the settings right into there.
So let's spend some time and now and look at what these let's look like in practice.