Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

help with powershell script.

Posted on 2015-02-03
13
Medium Priority
?
157 Views
Last Modified: 2016-09-07
Hello,
Could you please help with the powershell script. It doesn't give me any error and doesnt run.

Here is the script.

https://gallery.technet.microsoft.com/scriptcenter/Group-Policy-Status-5ac117fd

When I run it, this is what I get

PS C:\Script-GPOStatus> .\Get-GPStatus.ps1

PS C:\Script-GPOStatus> $Env:USERPROFILE\Desktop\Get-GPStatus.ps1
At line:1 char:17
+ $Env:USERPROFILE\Desktop\Get-GPStatus.ps1
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '\Desktop\Get-GPStatus.ps1' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken
0
Comment
Question by:creative555
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
  • 2
  • +1
13 Comments
 

Author Comment

by:creative555
ID: 40587360
I dont understand the instructions provided....not sure what I need to specify and where in order to run it.

Thank you
0
 

Author Comment

by:creative555
ID: 40587369
This is not working: Do I need to put the name of my profile??


Load function stored on user desktop, get group policy status over the forest and record in a variable, export variable to csv file.
            
            ."$Env:USERPROFILE\Desktop\Get-GPStatus.ps1"
0
 
LVL 10

Expert Comment

by:Benjamin MOREAU
ID: 40587370
try to run :

.'$Env:USERPROFILE\Desktop\Get-GPStatus.ps1'
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 10

Expert Comment

by:Benjamin MOREAU
ID: 40587385
otherwise, just open powershell console, browse directory et run :

.\get-GPStatus.ps1
0
 
LVL 40

Expert Comment

by:Subsun
ID: 40587449
Script is written as a module. Save code to desktop folder and then you can import the module using following command..
Import-Module '$Env:USERPROFILE\Desktop\Get-GPStatus.ps1'

Open in new window


Once you complete the import you can use the commands shown in the example of the article..

Example..
Get-GPStatus 'MyDomainFQDN'

Open in new window

0
 

Author Comment

by:creative555
ID: 40588013
ok. that worked. but the excel  file that I received by running this command did not give me a good output.
$GPStatus = Get-GPStatus 'corp.domain.com' | Export-Csv -Path "$Env:USERPROFILE\Desktop\GPStatus5.csv" -Delimiter ';' –NoTypeInformation

But I received the output on the screen: Is there any other command I should run in order toget the list of GPOs such as empty ones, orphans, etc?

Processing

Preparing status record of Group Policy(ies) linked on Site(s) and Domain(s) listed below:
corp.domain.com
=> 391 Group Policy(ies) linked
Checking Link options : enabled, enforced, disabled
Preparing status record of Group Policy(ies) not linked on Site(s) or Domain(s) listed below but stored in the latter:

=> 25 Group Policy(ies) not linked
Adding status record(s) considering orphaned Group Policy Directory(ies)
=> 26 orphaned Directory(ies)
Checking Sysvol status:
- selecting Domain Controller to query
- Network Drive "Sysvol_0" on "\\server.domain\SYSVOL\corp.domain.com\Policies" already mounted
- checking Directory, Folder(s) and Setting(s) existence
- updating Sysvol status considering NTFRS conflict(s)
=> 16 NTFRS conflict(s)
0
 

Author Comment

by:creative555
ID: 40588017
oh. so I have to use each command from this script? The script is not going to run all the commands?


I also need to group them.....The excel file looks bad. It is not grouped and has bad results. Could you please help me with the command to select and group them so that I have for example list of empty GPOs, list of unlinked GPos, etc.

THank you so much!!
0
 

Author Comment

by:creative555
ID: 40588057
This script only shows on the screen the following below but doesn't identify which 26 Group Policies are not linked and what 53 orphaned directories are....Please help with running this script

=> 26 Group Policy(ies) not linked
Adding status record(s) considering orphaned Group Policy Directory(ies)
=> 53 orphaned Directory(ies)
0
 
LVL 40

Expert Comment

by:Subsun
ID: 40588304
You need to filter the results of Get-GPStatus cmdlet to get required result..
$GPStatus = Get-GPStatus 'corp.domain.com'
$GPStatus | ? { !($_.existsInPolicies) -and ($_.enabledOn -or $_.enforcedOn -or $_.disabledOn) } | Export-csv  "C:\orphaned_grouppolicy_links.csv" -nti
$GPStatus | ? { !($_.existsInPolicies) -and $_.sysvol -ne 'no_Directory' }  | Export-csv  "C:\ orphaned_GroupPolicy_Directory.csv" -nti

Open in new window

1
 

Author Comment

by:creative555
ID: 40589054
Do I need to copy and paste one line by one into the powershell? Or I can copy three rows and paste it?
0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 40589059
Either way it will work.. Make sure you import the module first and then run these commands..
0
 

Author Closing Comment

by:creative555
ID: 40602154
THank you so much!! Script worked like you said
0
 
LVL 8

Expert Comment

by:Senior IT System Engineer
ID: 41788947
OK creative555, so does the script only list the GPO not doing anything to the existing production GPO ?
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question