Powershell script: to get the AD Security Group Name
I need PowerShell script that takes input: AD Security Group Name and loop
through all web applications and their content in the farm to know where this particular group is used.
hi
AD groups are represented in Sharepoint as SPUser object with
SPUser.IsDomainGroup set to true. I.e. you may use the same script which is used for users:
Powershell script to find permissions for a specific user.
Blog - http://sadomovalex.blogspot.com
Dynamic CAML queries via C# - http://camlex.codeplex.com
Similar Messages
-
Powershell script to get the low disk space on the servers...
Hi,
We have many SQL & Sharepoint servers running on windows server. I need some Powershell script to get the low disk space on those servers and it should send an mail alert saying "Disc d:\ have less than threshold 15% free space".
Awaiting for response.
Thanks
Anilyou should be able to use this powershell script which you can run as a scheduled task.
just change the details at the start of the script to point the script to the right location to create log files. you will need to have a plain text file containing a list of server names or ip addresses that you want to check drive space on.
# Change the following variables based on your environment
#specify the path to the file you want to generate containing drive space information
$html_file_dir = "\\server\share\DriveSpace"
#specify the path and file name of the text file containing the list of servers names you want to check drive space on - each server name on a seperate line in plain text file
$server_file = "\\server\share\servers.txt"
#speicfy the from address for the email
$from_address = "[email protected]"
#specify the to address for the email
$to_address = "[email protected]"
#specify the smtp server to use to send the email
$email_gateway = "smtp.domain.com" # Can either be DNS name or IP address to SMTP server
# The seventh line from the bottom (line 167) is used if your smtp gateway requires authentication. If you require smtp authentication
# you must uncomment it and set the following variables.
$smtp_user = ""
$smtp_pass = ""
# Change the following variables for the style of the report.
$background_color = "rgb(140,166,193)" # can be in rgb format (rgb(0,0,0)) or hex format (#FFFFFF)
$server_name_font = "Arial"
$server_name_font_size = "20px"
$server_name_bg_color = "rgb(77,108,145)" # can be in rgb format (rgb(0,0,0)) or hex format (#FFFFFF)
$heading_font = "Arial"
$heading_font_size = "14px"
$heading_name_bg_color = "rgb(95,130,169)" # can be in rgb format (rgb(0,0,0)) or hex format (#FFFFFF)
$data_font = "Arial"
$data_font_size = "11px"
# Colors for space
$very_low_space = "rgb(255,0,0)" # very low space equals anything in the MB
$low_space = "rgb(251,251,0)" # low space is less then or equal to 10 GB
$medium_space = "rgb(249,124,0)" # medium space is less then or equal to 100 GB
#### NO CHANGES SHOULD BE MADE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
# Define some variables
$ErrorActionPreference = "SilentlyContinue"
$date = Get-Date -UFormat "%Y%m%d"
$html_file = New-Item -ItemType File -Path "$html_file_dir\DiskSpace_$date.html" -Force
# Create the file
$html_file
# Function to be used to convert bytes to MB or GB or TB
Function ConvertBytes {
param($size)
If ($size -lt 1MB) {
$drive_size = $size / 1KB
$drive_size = [Math]::Round($drive_size, 2)
[string]$drive_size + ' KB'
}elseif ($size -lt 1GB){
$drive_size = $size / 1MB
$drive_size = [Math]::Round($drive_size, 2)
[string]$drive_size + ' MB'
}ElseIf ($size -lt 1TB){
$drive_size = $size / 1GB
$drive_size = [Math]::Round($drive_size, 2)
[string]$drive_size + ' GB'
}Else{
$drive_size = $size / 1TB
$drive_size = [Math]::Round($drive_size, 2)
[string]$drive_size + ' TB'
# Create the header and footer contents of the html page for output
$html_header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Server Drive Space</title>
<style type="text/css">
.serverName { text-align:center; font-family:"' + $server_name_font + '"; font-size:' + $server_name_font_size + `
'; font-weight:bold; background-color: ' + $server_name_bg_color + '; border: 1px solid black; width: 150px; }
.headings { text-align:center; font-family:"' + $heading_font + '"; font-size:' + $heading_font_size + `
'; font-weight:bold; background-color: ' + $heading_name_bg_color + '; border: 1px solid black; width: 150px; }
.data { font-family:"' + $data_font + '"; font-size:' + $data_font_size + '; border: 1px solid black; width: 150px; }
#dataTable { border: 1px solid black; border-collapse:collapse; }
body { background-color: ' + $background_color + '; }
#legend { border: 1px solid black; ; right:500px; top:10px; }
</style>
<script language="JavaScript" type="text/javascript">
<!--
function zxcWWHS(){
if (document.all){
zxcCur=''hand'';
zxcWH=document.documentElement.clientHeight;
zxcWW=document.documentElement.clientWidth;
zxcWS=document.documentElement.scrollTop;
if (zxcWH==0){
zxcWS=document.body.scrollTop;
zxcWH=document.body.clientHeight;
zxcWW=document.body.clientWidth;
else if (document.getElementById){
zxcCur=''pointer'';
zxcWH=window.innerHeight-15;
zxcWW=window.innerWidth-15;
zxcWS=window.pageYOffset;
zxcWC=Math.round(zxcWW/2);
return [zxcWW,zxcWH,zxcWS];
window.onscroll=function(){
var img=document.getElementById(''legend'');
if (!document.all){ img.style.position=''fixed''; window.onscroll=null; return; }
if (!img.pos){ img.pos=img.offsetTop; }
img.style.top=(zxcWWHS()[2]+img.pos)+''px'';
//-->
</script>
</head>
<body>'
$html_footer = '</body>
</html>'
# Start to create the reports file
Add-Content $html_file $html_header
# Retrieve the contents of the server.txt file, this file should contain either the
# ip address or the host name of the machine on a single line. Loop through the file
# and get the drive information.
Get-Content $server_file |`
ForEach-Object {
# Get the hostname of the machine
$hostname = Get-WmiObject -Impersonation Impersonate -ComputerName $_ -Query "SELECT Name From Win32_ComputerSystem"
$name = $hostname.Name.ToUpper()
Add-Content $html_file ('<Table id="dataTable"><tr><td colspan="3" class="serverName">' + $name + '</td></tr>
<tr><td class="headings">Drive Letter</td><td class="headings">Total Size</td><td class="headings">Free Space</td></tr>')
# Get the drives of the server
$drives = Get-WmiObject Win32_LogicalDisk -Filter "drivetype=3" -ComputerName $_ -Impersonation Impersonate
# Now that I have all the drives, loop through and add to report
ForEach ($drive in $drives) {
$space_color = ""
$free_space = $drive.FreeSpace
$total_space = $drive.Size
$percentage_free = $free_space / $total_space
$percentage_free = $percentage_free * 100
If ($percentage_free -le 5) {
$space_color = $very_low_space
}elseif ($percentage_free -le 10) {
$space_color = $low_space
}elseif ($percentage_free -le 15) {
$space_color = $medium_space
Add-Content $html_file ('<tr><td class="data">' + $drive.deviceid + '</td><td class="data">' + (ConvertBytes $drive.size) + `
'</td><td class="data" bgcolor="' + $space_color + '">' + (ConvertBytes $drive.FreeSpace) + '</td></tr>')
# Close the table
Add-Content $html_file ('</table></br><div id="legend">
<Table><tr><td style="font-size:12px">Less then or equal to 5 % free space</td><td bgcolor="' + $very_low_space + '" width="10px"></td></tr>
<tr><td style="font-size:12px">Less then or equal to 10 % free space</td><td bgcolor="' + $low_space + '" width="10px"></td></tr>
<tr><td style="font-size:12px">Less then or equal to 15 % free space</td><td bgcolor="' + $medium_space + '" width="10px"></td></tr>
</table></div>')
# End the reports file
Add-Content $html_file $html_footer
# Email the file
$mail = New-Object System.Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($html_file)
$mail.From = $from_address
$mail.To.Add($to_address)
$mail.Subject = "Server Diskspace $date"
$mail.Body = "The diskspace report file is attached."
$mail.Attachments.Add($att)
$smtp = New-Object System.Net.Mail.SmtpClient($email_gateway)
#$smtp.Credentials = New-Object System.Net.NetworkCredential($smtp_user,$smtp_pass)
$smtp.Send($mail)
$att.Dispose()
# Delete the file
Remove-Item $html_file
Regards,
Denis Cooper
MCITP EA - MCT
Help keep the forums tidy, if this has helped please mark it as an answer
My Blog
LinkedIn: -
Hi Experts,
I am trying to build a PowerShell Script to get the details Like Scope,Last Deployed date and Name for a Solution Deployed in the Farm.
Can anyone advise on this please.
RegardsGet-SPSolution|Select Name,Scope,LastOperationResult,LastOperationEndTime|Export-CSV "SPInstalledSolutions.csv" -NoTypeInformation
SPSolution properties
Get-SPSolution
This post is my own opinion and does not necessarily reflect the opinion or view of Slalom. -
SQL or Powershell query to get the SCOM management group id for SCOM 2007 R2 & 2012 / 2012 R2
Hi All,
Can any one provide me the SQL or Powershell query to get the SCOM management group id for SCOM 2007 R2 & 2012 / 2012 R2
I had a SQL query which will query the data from data warehouse and give the management group id but i have lost it for all 3 above.
Gautam.75801Hi Gautam,
Hope it helps:
http://blog.tyang.org/2013/03/13/data-aggregation-field-became-empty-in-opsmgr-2007-linked-performance-report/
http://blog.tyang.org/2012/09/05/mp-authoring-targeting-rms-or-ms/
Natalya
### If my post helped you, please take a moment to Vote as Helpful and\or Mark as an Answer -
Powershell script to Get members of AD group members with first, last, email address
I'm running a powershell script to retrieve AD users from a specific AD group and pipe specific attributes to a csv file. The script is working perfectly except for one detail. I want the script to ignore any users who have a null value in any of the values
I'm piping to the spreadsheet. Meaning that if any of the users found in the queried groups have a null value in the attributes givenname, sn or mail, ignore the user and do not pipe to the csv.
Get-ADGroupMember -identity adgroup -recursive | get-adobject -Properties givenname,sn,mail | select givenname,sn,mail |export-csv -path c:\powershell\groupmembers.csv
–NoTypeInformationHi,
You can pipe your user objects through ForEach-Object and then use if to verify all three properties exist. If so, output the object. If not, move to the next object. After you've processed all user objects, then pipe into Export-Csv.
EDIT: See below.
Don't retire TechNet! -
(Don't give up yet - 13,225+ strong and growing) -
Powershell script to get the domain admin list from non domian member server
hello Script guys!
I am new of the powershell scripting.
currently I am working on autometion project , we would like generate a privilege report for our existing servers.
in our environment, there are many seprated domain , we would like generate the report from one server instead to login each server to check , could you provide some guide on how can we get the specific domain admin list for each domain from a non domain
membership server by using the powershell script? many thanks for your help.You could remote to the domain controller or use ADSI to query the domain.
Look inth eGallery as ther eare many scripts there tha will return group membership using ADSI.
¯\_(ツ)_/¯ -
Powershell script to get the list of pages using a particular webpart in SharePoint 2013
I want to find all the pages withing a web application or site collection on which particular webpart is enabled. I have seen the link
http://www.glynblogs.com/2011/07/listing-all-web-parts-in-a-site-collection-with-powershell.html but it doesnt work for default.aspx.please suggestfound a script at
https://gallery.technet.microsoft.com/List-all-web-parts-in-page-afc7840f
Please Mark it as answer if this reply helps you in resolving the issue,It will help other users facing similar problem -
Powershell script to change the a column value of all documents in a site.
Hi,
I need a powershell script to change the value of a column (a site column which has been added to all document libraries) in all documents in a site,
For example:
-column 1 is a site column added to all libraries
the value of column 1 of all documents under this site: http://intranet.doman/ex1 should be equal to V1
the value of column 1 of all documents under this site: http://intranet.doman/ex2 should be equal to V2
So, if I can write a powershell script to change the value of all documents in a site, I can modify it for different site that I have and run it for each of them individually,cls
# Is dev version?
$dev = $false
# Configuration
$termStore = "Managed Metadata Service"
$group = "G1"
$subjectMatterTermSetName = "Subject Matter"
# Check if SharePoint Snapin is loaded
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Taxonomy") | Out-Null
function GetTermStore($site, $termStore, $group, $termSet) {
$session = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)
$termStore = $session.TermStores[$termStore]
$group = $termStore.Groups[$group]
$termSet = $group.TermSets[$termSet]
return $termSet
if($dev) {
Write-Host "Running DEV version..."
$webUrl = "http://Site1"
$libraryName = "L1"
$subjectMatter = "C1"
} else {
$webUrl = Read-Host "Enter Site URL"
$libraryName = Read-Host "Enter Document Library name"
$subjectMatter = Read-Host "Enter Subject Matter"
try {
$web = Get-SPWeb $webUrl
$site = $web.Site
$library = $web.Lists[$libraryName]
$items = $library.GetItems()
$subjectMatterTermSet = GetTermStore $site $termStore $group $subjectMatterTermSetName
$subjectMatterTerm = $subjectMatterTermSet.GetTerms($subjectMatter,$true) | select -First 1
foreach($item in $items) {
if([string]::IsNullOrEmpty($item["Subject Matter"])) {
#Write-Host "Filename: $filename / Keywords: $keywords / Subject Matter: $subjectMatter / Document Type: $documentType"
Write-Host "Updating $($item["ows_FileLeafRef"])..."
# Set Subject Matter column
$subjectMatterField = [Microsoft.SharePoint.Taxonomy.TaxonomyField]$item.Fields["Subject Matter"]
$subjectMatterField.SetFieldValue($item,$subjectMatterTerm)
# Update Item
$item.SystemUpdate()
catch
$ErrorMessage = $_.Exception.Message
Write-Host "Something went wrong. Error: $ErrorMessage" -ForegroundColor Red -
Need VB script for getting the IIS certification information
Hi guys,
I have totally 1000 IIS servers 2003 & 2008
windows and some of the servers configured
IIS 3rd party Security certificates. I need a script to get the certification information like expiry date & certificate vendor name.
Regards,
SreeMPost here:http://forums.iis.net/
Look in Gallery for IIS scripts:http://gallery.technet.microsoft.com/
¯\_(ツ)_/¯ -
Powershell script to get Site Collection. Site Owner, Title
Hi,
I am new to SharePoint, currently I have given one task to create the powershell script which contains the below fields from our two farms. Could you please help me out with the same.
The script to list out below items:
Site Collections:
Site Collection Name:
Site Collection Owners:
Last Activity and the size of site collections.
Many Thanks & Best Regards,
NarenTo get all Site Collections:
If all you want is a list of all site collections in the farm, all you have to do is open a PowerShell window, load the SharePoint Snapin, if you haven't (Add-PSSnapin
Microsoft.SharePoint.PowerShell), and type Get-SPSite.
If you want to return the list of site collections for a specific web application, the easiest way is to just pipe it as Get-SPWebApplication
http://intranet | Get-SPSite
To get Site Collection Owners:
Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue
Get-SPWebApplication "http://mySharePointSite.com"|
Get-SPSite| foreach-object{ Write-host$_.Url - $_.Owner.Email}
To get Size of all Site Collections:
Get-SPSite | select url, @{label"Size in MB";Expression={$_.usage.storage/1MB}} | Sort-Object
-Descending -Property "Size in MB" | ConvertTo-Html -title "Site Collections sort by size" | Set-Content sc.html
Regrading the retrieving the last activity I am not sure to what exactly you are looking for but I assume you are concern about getting users last logon time and date using PowerShell.
For this refer here: Get Users Last Logon Time and Date using PowerShell
Please remember to upvote if it helps you or
click 'Mark as Answer' if the reply answers your query. -
BO XI 3.1 : Active Directory Authentication failed to get the Active Directory groups
Dear all
In our environment, there are 2 domain (domain A and B); it works well all the time. Today, all the user belong to domain A are not logi n; for user in domain B, all of them can log in but BO server response is very slowly. and there is error message popup when opening Webi report for domain B user. Below are the error message:
" Active Directory Authentication failed to get the Active Directory groups for the account with ID:XXXX; pls make sure this account is valid and belongs to an accessible domain"
Anyone has encountered similar issue?
BO version: BO XI 3.1 SP5
Authenticate: Windows AD
Thanks and RegardsPlease get in touch with your AD team and verify if there are any changes applied to the domain controller and there are no network issues.
Also since this is a multi domain, make sure you have 2 way transitive forest trust as mentioned in SAP Note : 1323391 and FQDN for Directory servers are maintained in registry as per 1199995
http://service.sap.com/sap/support/notes/1323391
http://service.sap.com/sap/support/notes/1199995
-Ambarish- -
Which WSDL file to get the list of Groups present in OAM.
Hi All,
Can any one tell me which WSDL file is to be used to get the list of groups present in OAM from an IDXML call.
Please provide sample IDXML call if possible.
Thanks in advance.
Thanks & Regards,
Siva Pokuri.guys, 80% of my problem got solved.
here is the solution list as u all have suggested and that i have checked it also.
RSDCUBEIOBJ - infocube list for any nav-attr
RSDODSOATRNAV - DSO list for any nav-attr
ODSOIOBJ. - DSO list for any infoobj
but in these tables, one thing i observe is that each infocube/DSO name is repeated multiple times. why is that? from where it populate? -
What is the powershell command to get the user count in Active Directory
What is the powershell command to get the user count in Active Directory
Get-ADuser
REF: http://blogs.technet.com/b/heyscriptingguy/archive/2012/10/30/powertip-single-line-powershell-command-to-list-all-users-in-an-ou.aspx
This post is provided AS IS with no warranties or guarantees, and confers no rights.
~~~
Questo post non fornisce garanzie e non conferisce diritti -
I'm getting the wrong security code warning
I'm getting the wrong security code warning
Hi..
Try here > iTunes Store: My credit card's security code or zip code does not match my bank's records -
Hello,
I have a big problem with Reporting Services 2005 working on Windows 2003 Server.
RS work as Network service, on subdomain reporting.mydomain with SSL wildcard certificate *.mydomain,
Anonymous access: disabled and basic authentication: enabled
ReportManager and reportServer has defualt virtual folders (/reporting, /reportserver)
My problem is:
1) I can't manage security roles and site settings with report maanger. when I try assign roles to new user or group I get followng error:
"The user or group name 'BUILTIN\Administrators' is not recognized. (rsUnknownUserName) Get Online Help"
when i try to execute reports in report manager, parameters controls are not displayed correctly (very simple text boxes) and I can see:
The selected report is not ready for viewing. The report is still being rendered or a report snapshot is not available. (rsReportNotReady)
and I can't see my report in browser (IE 6.0) but only export to PDF, Excel...
other functionality are working fine i.e upload new files, creatign folders....
2) Also my reportserver virtual folder does not work correctly.
When I navigate to mydomain/reportserver I can see content of this virtual folder, than when I navigate to ReportService.soap i can see normal ReportServer view
reporting.mydomain - /Reportserver/
[To Parent Directory]
Montag, 10. April 2006 16:31 <dir> bin
Dienstag, 6. September 2005 01:12 488278 Catalog.sql
Dienstag, 6. September 2005 01:12 14738 CatalogTempDB.sql
Freitag, 21. April 2006 19:45 10555 Copy of rsreportserver.config
Freitag, 14. April 2006 17:29 76 global.asax
Freitag, 15. Juli 2005 01:12 26582 ModelGenerationRules.smgl
Montag, 10. April 2006 16:31 <dir> Pages
Montag, 10. April 2006 16:31 <dir> ReportBuilder
Montag, 13. Juni 2005 14:07 143 ReportExecution2005.asmx
Montag, 13. Juni 2005 14:06 196337 ReportingServices.wsdl
Montag, 13. Juni 2005 14:07 131 ReportService.asmx
Montag, 13. Juni 2005 14:07 131 ReportService.soap
Montag, 13. Juni 2005 14:07 139 ReportService2005.asmx
Dienstag, 13. Juni 2006 20:01 10580 rsreportserver.config
Montag, 13. Juni 2005 14:07 11845 rssrvpolicy.config
Montag, 10. April 2006 16:31 <dir> Styles
Freitag, 17. Juni 2005 01:09 2673 web.config
but me reports are not displayed correctly, I can run reports but top bar with parameters, export and print function are not displayed in correct format.
(simple textboxes, and icons)
reporting.mydomain/ReportServer - /
Microsoft SQL Server Reporting Services Version 9.00.1399.00
I think it is security issue. What schould i do to solve this problems?
WojtekHi Wojtek
I just wanted to know if you found a solution for part (1). I just recently encountered the problem where:
"when i try to execute reports in report manager, parameters controls are not displayed correctly (very simple text boxes) and I can see:
The selected report is not ready for viewing. The report is still being rendered or a report snapshot is not available. (rsReportNotReady) "
However all my reports are run from the most recent data. The rsReportNotReady message appears in Report Manager but not the Report Server interface; the latter is able to render the reports. But both have incorrectly displayed textbox inputs.
Thanks
nemo
Maybe you are looking for
-
[Solved] Report on Issue with Kernel Config with Nvidia Graphics
I switched back to Archlinux from Gentoo recently and I have been having problems with the system freezing during boot before X is started, even with the nvidia module blacklisted. Trying several module versions yielded different results, all of whi
-
Function to get the date after substraction
Hi Gurus, I understand that the function "RE_ADD_MONTH_TO_DATE" is used for calculate the date after added certain month(s). But, how do I do it in the other way. What I mean here is I want to substract the date. For example my current date is 09.05.
-
How Do I "Re-Write" a Canon RAW file or a Nikon RAW File, Undetected
I need to "re-write" a native camera RAW file and do it undetected. Can Aperture or any software tool, on any platform accomplish this goal?
-
MacBook Pro using too much RAM
I have 15" MacBook Pro, purchased in February, 2013. It has 2.6 Ghz Intel i7 processor, 8 GB RAM and a 750 GB hard drive. The HD is about 25% filled, mostly with photos. It came with Mountain Lion, I upgraded to Mavericks, then to Yosemite. I go
-
Singapore - nric field in personal data
Hello, we noticed that the field NRIC in the personal data for singapore has been greyed out. Is there a way to activate this ? Or has this a particular reason ? thanks in advance !