PowerShell script to check permissions given to "NT Authority\All Authenticated Users" and..

Hi there,
On my SharePoint site - some places (Sites/Lists etc) have given permissions to "NT Authority\All Authenticated Users"
We need to remove these permissions and instead give permissions to "Forest1\Domain Users" and "Forest1\Domain Users"
PowerSHell script to do above will be appreciated.
Thank you so much.

Hello,
In order to check whether "NT Authority\All Authenticated Users" are present in your site use this reference - Link
Remove permission script reference - Link
Finally grant permission script reference - link
Kindly mark it as answer if it helps you.
-Hatim

Similar Messages

  • Windows vista system, continuously trying to download a DRM file in Adobe Digital Editions application shows "Error check activation". I have authorized the Fire Wall and still the same.

    windows vista system, continuously trying to download a DRM file in Adobe Digital Editions application shows "Error check activation". I have authorized the Fire Wall and still the same.

    Since Re-activation as suggested by the link above is not working for you, Can you please confirm the following:
    The OperatorURL is reachable. ( you can find the operatorURL from the acsm file by opening it in notepad,etc)
    And Book is still available on the book-store for purchase.
    (If any of first two are not available, you might have to talk to distributor for next action item to get the book. Since you will have record of purchasing the book, (in my opinion) they should provide you the new token for downloading the book)
    And please confirm this that you used the same userID for downloading that you used when you first fulfilled/downloaded the book.
    (If it is the case, then you have to use the correct userID)
    I hope it helps.

  • Executing a powershell script for checking duplicate users while creating a AD user throug ADUC console.

    Hi,
    I have a text file in which some SamAccountNames are present.I need to check the file while creating a new users through ADUC console.If a username that is going to create through ADUC console is present in the file, then it should prompt a message
    that the user is already present in the text file.
    Is there any possibility of contacting the powershell script from the ADUC console.If so, then while creating a new user through ADUC console, what is the proceedure for executing that powershell script.
    please provide me the approriate solutions.
    Thanks
    Prasanthi k

    Run the below Powershell Script for users are exist or not in AD. Later you can create the users.
    #Find Users exist in AD or Not?
    #Biswajit Biswas
    $users = get-content c:\users.txt
    foreach ($user in $users) {
    $User = Get-ADUser -Filter {(samaccountname -eq $user)}
    If ($user -eq $Null) {"User does not exist in AD ($user)" }
    Else {"User found in AD ($user)"}
    Active Directory Users attributes-Powershell
    http://gallery.technet.microsoft.com/scriptcenter/Getting-Users-ALL-7417b71d
    Regards~Biswajit
    Disclaimer: This posting is provided & with no warranties or guarantees and confers no rights.
    MCP 2003,MCSA 2003, MCSA:M 2003, CCNA, MCTS, Enterprise Admin
    MY BLOG
    Domain Controllers inventory-Quest Powershell
    Generate Report for Bulk Servers-LastBootUpTime,SerialNumber,InstallDate
    Generate a Report for installed Hotfix for Bulk Servers

  • Powershell script for mailbox permissions

    Hello,
    Part of my tasks as an Exchange admin is to give access to shared mailboxes. The access usually are:
    Send AS
    Receive As
    Send on Behalf Of
    Full mailbox
    Is there a powershell script out there that does all of the above?
    thanks,
    Alexis

    Hi,
    Probably not prewritten, but you can check the repository for starters:
    http://gallery.technet.microsoft.com/scriptcenter
    EDIT: I should mention - this isn't too hard to write, so this could be a good opportunity to learn how to get around in the EMS.
    Don't retire TechNet! -
    (Don't give up yet - 12,830+ strong and growing)

  • Powershell script to check IP of Website

    Yes, true enough. I was thinking more along the lines of a simple check to see if the site went "down" but had actually changed IP.

    Personally, I would recommend using a graphical monitor likePRTG. The free version allows for up to 100sensors. You canuse the DNS sensor to monitor for IP address changes of the DNS address and if it doesn't match it can alert.
    But here's a PowerShell Script (replace the values of the variables at the beginning of the script):Powershell$WebsiteAddress = "resolver1.opendns.com"$IPAddress = "208.67.222.222"$ToEmailAddress = "[email protected]"$FromEmailAddress = "[email protected]"$MailServer = "mail.domain.com"Clear-DNSClientCache$ResolvedWebsite = Resolve-DNSName $WebsiteAddressIf ($ResolvedWebsite.IPAddress -ne $IPAddress) {Send-MailMessage -To $ToEmailAddress -From $FromEmailAddress -SmtpServer $MailServer -Subject "Notification: $WebsiteAddress IP Address Change" -Body "The IP address for $WebsiteAddress has changed to $(...

  • 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

  • PowerShell script cannot find user permissions given directly (can find if permissions given in a group) - Please help.

    Hi there,
    I need to find ALL SharePOint sites/subsites/locations where "Domain\john" has any level of access. 
    Following script works if the permissions were given to Domain\john via a group - but this does not work if the permissions were given directly to the user (i.e. user is NOT part of the group).
    $weburl = "http://dev"
    Get-SPUser -web $weburl -Limit All | ?{$_.UserLogin -eq "Domin\john"} | select UserLogin, @{name="Url";expression={$_.ParentWeb.Url}}, @{name="Explicit given roles";expression={$_.Roles}}, @{name="Roles given via groups";expression={$_.Groups | %{$_.Roles}}},Groups | Out-String -Width 4096
    Help will be appreciated.
    Thank you.

    I don't really understand your request. It sounds like you just want to know the permissions per-user
    $weburl = "http://dev"
    Get-SPUser -web $weburl -Limit All | ?{$_.UserLogin} | select UserLogin, @{name="Url";expression={$_.ParentWeb.Url}}, @{name="Explicit given roles";expression={$_.Roles}}, @{name="Roles given via groups";expression={$_.Groups | %{$_.Roles}}},Groups | Out-String -Width 4096
    This will just return all the users and their permissions.
    If this is helpful please mark it so. Also if this solved your problem mark as answer.

  • Powershell Script to find out Orphan Users ( Who are no longer available in AD but SharePoint) in SharePoint 2013

    Hi,
    Can you please on the above issue? I have one script which works fine for sp2010 but not sp2013 below,
    Script
    function Check_User_In_ActiveDirectory([string]$LoginName, [string]$domaincnx)
    $returnValue = $false
    #Filter on User which exists and activated
    #$strFilter = "(&(objectCategory=user)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2)(samAccountName=$LoginName))"
    #Filter on User which only exists
    #$strFilter = "(&(objectCategory=user)(objectClass=user)(samAccountName=$LoginName))"
    #Filter on User and NTgroups which only exists
    $strFilter = "(&(|(objectCategory=user)(objectCategory=group))(samAccountName=$LoginName))"
    $objDomain = New-Object System.DirectoryServices.DirectoryEntry($domaincnx)
    $objSearcher = New-Object System.DirectoryServices.DirectorySearcher
    $objSearcher.SearchRoot = $objDomain
    $objSearcher.PageSize = 1000
    $objSearcher.Filter = $strFilter
    $objSearcher.SearchScope = "Subtree"
    #$objSearcher.PropertiesToLoad.Add("name")
    $colResults = $objSearcher.FindAll()
    if($colResults.Count -gt 0)
    #Write-Host "Account exists and Active: ", $LoginName
    $returnValue = $true
    return $returnValue
    function ListOrphanedUsers([string]$SiteCollectionURL, [string]$mydomaincnx)
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
    $site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL)
    $web = $site.openweb()
    #Debugging - show SiteCollectionURL
    write-host "SiteCollectionURL: ", $SiteCollectionURL
    Write-Output "SiteCollectionURL - $SiteCollectionURL"
    $siteCollUsers = $web.SiteUsers
    write-host "Users Items: ", $siteCollUsers.Count
    foreach($MyUser in $siteCollUsers)
    if(($MyUser.LoginName.ToLower() -ne "sharepoint\system") -and ($MyUser.LoginName.ToLower() -ne "nt authority\authenticated users") -and ($MyUser.LoginName.ToLower() -ne "nt authority\local service"))
    #Write-Host "  USER: ", $MyUser.LoginName
    $UserName = $MyUser.LoginName.ToLower()
    $Tablename = $UserName.split("\")
    Write-Host "User Login: ", $MyUser.LoginName
    $returncheck = Check_User_In_ActiveDirectory $Tablename[1] $mydomaincnx 
    if($returncheck -eq $False)
    #Write-Host "User not exist: ",  $MyUser.LoginName, "on domain", $mydomaincnx 
    Write-Output $MyUser.LoginName 
    $web.Dispose()
    $site.Dispose()
    function ListOrphanedUsersForAllColl([string]$WebAppURL, [string]$DomainCNX)
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
    $Thesite = new-object Microsoft.SharePoint.SPSite($WebAppURL)
    $oApp = $Thesite.WebApplication
    write-host "Total of Site Collections: ", $oApp.Sites.Count
    $i = 0
    foreach ($Sites in $oApp.Sites)
    $i = $i + 1
    write-host "Collection N° ", $i, "on ", $oApp.Sites.Count
    if($i -gt 0)
    $mySubweb = $Sites.RootWeb
    $TempRelativeURL = $mySubweb.Url
    ListOrphanedUsers $TempRelativeURL $DomainCNX
    function StartProcess()
    # Create the stopwatch
    [System.Diagnostics.Stopwatch] $sw;
    $sw = New-Object System.Diagnostics.StopWatch
    $sw.Start()
    #cls
    ListOrphanedUsersForAllColl "http://portal" "LDAP://DC=Srabon,DC=com" 
    ListOrphanedUsersForAllColl "http://portal/sites/Test" "LDAP://DC=Srabon,DC=com"  
    $sw.Stop()
    # Write the compact output to the screen
    write-host "Time: ", $sw.Elapsed.ToString()
    StartProcess
    # Can be executed with that command : "Check-SharePoint-Orphaned-Users.ps1 > orphaned_users.txt"
    srabon

    Hi Srabon,
    Try this it works in SP2007, SP2010, and SP2013.
    Mod line 70: $WebAppURL="http://intranet.contoso.com" to your "http://WebApp"
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    #Functions to Imitate SharePoint 2007, 2010, 2013
    function global:Get-SPWebApplication($WebAppURL)
    return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL)
    function global:Get-SPSite($url)
    return new-Object Microsoft.SharePoint.SPSite($url)
    function global:Get-SPWeb($url)
    $site= New-Object Microsoft.SharePoint.SPSite($url)
    if ($site -ne $null)
    $web=$site.OpenWeb();
    return $web
    #Check if User exists in ActiveDirectory
    function CheckUserExistsInAD()
    Param( [Parameter(Mandatory=$true)] [string]$UserLoginID )
    #Search the User in ActiveDirectory
    $forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
    foreach ($Domain in $forest.Domains)
    $context = new-object System.DirectoryServices.ActiveDirectory.DirectoryContext("Domain", $Domain.Name)
    $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetDomain($context)
    $root = $domain.GetDirectoryEntry()
    $search = [System.DirectoryServices.DirectorySearcher]$root
    $search.Filter = "(&(objectCategory=User)(samAccountName=$UserLoginID))"
    $result = $search.FindOne()
    if ($result -ne $null)
    return $true
    return $false
    $WebAppURL="http://intranet.contoso.com"
    #Get all Site Collections of the web application
    $WebApp = Get-SPWebApplication $WebAppURL
    #Iterate through all Site Collections
    foreach($site in $WebApp.Sites)
    #Get all Webs with Unique Permissions - Which includes Root Webs
    $WebsColl = $site.AllWebs | Where {$_.HasUniqueRoleAssignments -eq $True} | ForEach-Object {
    $OrphanedUsers = @()
    #Iterate through the users collection
    foreach($User in $_.SiteUsers)
    #Exclude Built-in User Accounts , Security Groups & an external domain "corporate"
    if (($User.LoginName.ToLower() -ne "nt authority\authenticated users") -and
    ($User.LoginName.ToLower() -ne "sharepoint\system") -and
    ($User.LoginName.ToLower() -ne "nt authority\local service") -and
    ($user.IsDomainGroup -eq $false ) -and
    ($User.LoginName.ToLower().StartsWith("corporate") -ne $true) )
    $UserName = $User.LoginName.split("\") #Domain\UserName
    $AccountName = $UserName[1] #UserName
    if ( ( CheckUserExistsInAD $AccountName) -eq $false )
    Write-Host "$($User.Name)($($User.LoginName)) from $($_.URL) doesn't Exists in AD!"
    #Display Orphaned users
    $OrphanedUsers+=$User.LoginName
    # <<<UNCOMMENT to Remove Users#
    # Remove the Orphaned Users from the site
    # foreach($OrpUser in $OrphanedUsers)
    # $_.SiteUsers.Remove($OrpUser)
    # Write-host "Removed the Orphaned user $($OrpUser) from $($_.URL) "
    $web.Dispose()
    $site.Dispose()
    -Ivan

  • How to export Powershell script information to Sharepoint?

    I'm trying to export information gather from a Powershell script to a Sharepoint list. I've got a couple of powershell scripts that gather general server information from a server ex: server uptime, disk space, service tag, etc. and it will export the information
    to a csv file. What I would like to do is out-put the same information gathered by the powershell scripts to a Sharepoint list directly if at all possible.
    Ex:
    # all this does is reads from a list and runs a script call "boottime.ps1"
    get-content "\\%Data-Path-Of-List%\computers.txt" | %Data-Path-Of-Script%\boottime.ps1 |  Export-csv %Data-Path-For-CSV\Computers.csv
    # then just exports the information from the boottime.ps1 script to a csv file
    #I also have a script that will upload the information to a sharepoint list.
    # I found that I have to run this in version 2 of powershell, so I just open a DOS prompt in Admin Priv's and type the following
    powershell.exe -version 2.0
    # Next I make sure the Sharepoint snap-in is loaded
    if ( (Get-PSSnapin -Name Microsoft.sharepoint.powershell - erroraction silentlycontinue) -eq $null)
    Add-PsSnapin Microsoft.Sharepoint.Powershell
    $spweb = get-SPweb $spserver
    $spdata =$spweb.getlist("%URL_Of_My_List%")
    # this is the same location from the orginal Powershell script previously stated.
    $ComputerInfoFile = "%Data-Path-For-CSV%\Computers.csv"
    foreach ($rows in $tblData) {
    # here is where I add the information from my csv file
    # 2 things needs to be present
    # 1st the colums have to be present in the sharepoint site before I can upload the information
    # 2nd the columns have to the headers in my csv file
    $spItem = $spData.AddItem()
    $SpItem["ServerName"] = $row."ServerName".toString()
    $SpItem["Uptime"] = $row."Uptime".toString()
    $SpItem.Update()
    # this just disconnects from Sharepoint
    $spWeb.Dispose()
    Please dismiss all the comments it just helps me understand what the code is doing, also if this is not the correct place to post this question I appologize in adavance and ask that if this is the incorrect place to post this question please provide me a
    link to a where I can post such questions.

    Sorry for the delay in posting this, but I ended up getting working. I'll post it in the hopes that my head scratching will save someone else some head scratching:
    I ended up writting 3 PS scripts and one batch job.
    1st Batch file
    powershell.exe -version 2.0 -command
    \\%Script-Location\Get-Server-Infor-4-SP.ps1
    powershell.exe -version 2.0 -command \\%Script-Location\Delete-list-Items.ps1"
    powershell -veriosn 2.0 -command
    \\%Script-Location\Populate-SP.ps1
    1st PS script that gets the info:
    get-content
    \\%Location-Of-My-File-With-List-Of-Servers%\%name-of-file%.txt |
    \\%Location-Of-My-Script-To-get-the-Information-I-want | Export-csv
    \\%location-of-my-output\%filename%.csv
    Ex: get-content C:\scripts\computers.txt | C:\scripts\boottime.ps1 | export-csv C:\scripts\computer.csv
    2nd PS script Delete-List-Items.ps1
    # http:
    #Script 1 Boottime.ps1:
    # This script permits to get UpTime from localHost or a set of remote Computer
    # usage
    # localHost
    # .\BootTime.ps1
    # set of remote computers
    # get-content .\MyserverList.txt | .\boottime.ps1
    # Optionally pipe output to Export-Csv, ConverTo-Html
    Process {
    $ServerName = $_
    if ($serverName -eq $Null) {
    $serverName= $env:COMPUTERNAME
    $timeVal = (Get-WmiObject -ComputerName $ServerName -Query "SELECT LastBootUpTime FROM Win32_OperatingSystem").LastBootUpTime
    #$timeVal
    $DbPoint = [char]58
    $Years = $timeVal.substring(0,4)
    $Months = $timeVal.substring(4,2)
    $Days = $timeVal.substring(6,2)
    $Hours = $timeVal.substring(8,2)
    $Mins = $timeVal.substring(10,2)
    $Secondes = $timeVal.substring(12,2)
    $dayDiff = New-TimeSpan $(Get-Date –month $Months -day $Days -year $Years -hour $Hours -minute $Mins -Second $Secondes) $(Get-Date)
    $Info = "" | select ServerName, Uptime
    $Info.servername = $servername
    $d =$dayDiff.days
    $h =$dayDiff.hours
    $m =$dayDiff.Minutes
    $s = $daydiff.Seconds
    $info.Uptime = "$d Days $h Hours $m Min $s Sec"
    $Info
    #Script 2: Delete-List-Items.ps1
    # http://markimarta.com/sharepoint/delete-all-items-in-sharepoint-list-using-powershell/
    # there seems to be a problem with running this script in version 3 or later, the workaround is to run it in version 2
    # below is the cmd for doing so, just open up a DOS prompt with Admin Privileges Start-->Run-->cmd
    # type then copy and paste the following line the DOS window then you can run this script
    #powershell.exe -version 2.0
    # make sure that the Microsoft.SharePoint.PowerShell Snap-in is installed as well
    if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
    Add-PsSnapin Microsoft.SharePoint.PowerShell
    # "Enter the site URL instead http://serverurl"
    $SITEURL = "%http://serverurl%"
    $site = new-object Microsoft.SharePoint.SPSite ( $SITEURL )
    $web = $site.OpenWeb()
    "Web is : " + $web.Title
    # Enter name of the List below in the [“%List-Name%”]
    $oList = $web.Lists["%List-Name%"];
    # This echo out the name of the list its going to be deleting the records from
    "List is :" + $oList.Title + " with item count " + $oList.ItemCount
    # It’s just counting the rows/records
    $collListItems = $oList.Items;
    $count = $collListItems.Count - 1
    # Here is where it is actually deleting the records and then out put the number or the record it deleted
    for($intIndex = $count; $intIndex -gt -1; $intIndex--)
    "Deleting record: " + $intIndex
    $collListItems.Delete($intIndex);
    #Script 3: Populate-SP_Test.ps1
    # http://blogs.technet.com/b/stuffstevesays/archive/2013/07/10/3577320.aspx
    # there seems to be a problem with running this script in version 3 or later, the workaround is to run it in veriosn 2
    # below is the cmd for doing so, just open up a DOS prompt with Admin Privileges Start-->Run-->cmd
    # type then copy and paste the following line the the DOS window then you can run this script
    #powershell.exe -version 2.0
    # make sure that the Microsoft.SharePoint.PowerShell Snap-in is installed
    if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
    Add-PsSnapin Microsoft.SharePoint.PowerShell
    # Here are some more varables that can be added I was not able to get this to work
    #$SPComputerInfo="/Lists/PowershellTest/"
    # Here is where we connect and Open SharePoint List via Powershell
    $SPServer= "%http://serverurl%
    $spWeb = Get-SPWeb $SPServer
    $spData = $spWeb.GetList("%List-Name%")
    # This is the variable for the path that has the file I want to input to SharePoint List
    $InvFile="\\%location-ofList%\computers.csv"
    # This is just some error checking to make sure the file exist
    $FileExists = (Test-Path $InvFile -PathType Leaf)
    if ($FileExists) {
    "Loading $InvFile for processing..."
    $tblData = import-csv $InvFile
    } else {
    "$InvFile not found - stopping import!"
    exit
    # Loop through Applications add each one to SharePoint
    "Uploading data to SharePoint...."
    foreach ($row in $tblData) {
    #Here is where I add the information from my CSV file
    #2 things have to be present
    # 1. the columns have to be in the sharepoint site before I can import the information
    # 2. columns have to the headers in my csv file
    #"Adding entry for "+$row."Computer Information".ToString()
    $spItem = $spData.AddItem()
    $spItem["ServerName"] = $row."ServerName".ToString()
    $spItem["Uptime"] = $row."Uptime".ToString()
    #$spItem["DNSHostName"] = $row."DNSHostName".ToString()
    #$spItem["DistinguishedName"] = $row."DistinguishedName".ToString()
    $spItem.Update()
    # This is just disconnecting from SharePoint
    $spWeb.Dispose()
    Enjoy, and if anyone has a better way of doing this I'm interested in knowing, thanks again
    Thanks in Adavance

  • Creating a powerhsell script to check for .ost files and delete all .ost files if there is any detected

    Hi Guys,
    I was hoping someone could help me with a PowerShell script to check a directory to see if any .ost files exist.
    If it detects any .ost files I want it to run this code:
    get-childitem "C:\Users\*" -include *.ost -recurse -force | foreach-object { remove-item $_ -force  }
    If it doesn't detect any .ost files I just want the script to exit.
    Looking to add this to our startup scripts in group policy
    Many thanks,

    Hi Tlewis4435,
    In addition, please refer to the script below:
    $files = get-childitem "D:\SHARE\*" -include *.ost -recurse -force
    if($files){ #detect files
    foreach($f in $files) { remove-item $f -force }
    else{exit} #if there is no file then exit powershell
    If there is anything else regarding this issue, please feel free to post back.
    If you have any feedback on our support, please click here.
    Best Regards,
    Anna Wang
    TechNet Community Support

  • 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

  • Powershell Script to list pdf files in a directory

    Hey Scripting guy, I read few of your forum solutions for the scripts and was really enthralled to embrace this powershell scripting, thanks for the motivation.
    I am still a learner and want to learn more, I had to do a script on generating an excel report which consisted of number of files of files in PDF format for each directory and sub-directory in the path.
    I used the,
    get-childitem $Path -recurse | where {$_.Extension -match "pdf"}
    command, all I wanted to know is how to count the number of PDF files in each sub directory, please help me out,
    Thanks in advance

    Ok, let's have some fun :)
    function Count-FilesRecursive{
    Param(
    [parameter(Mandatory = $true, Position = 0)]
    [string]$Path,
    [parameter(Mandatory = $true, Position = 1)]
    [string]$Filter
    $SB_recursive = {
    [System.IO.Directory]::GetDirectories($args[0])|ForEach-Object {
    Try{
    $i = ([System.IO.Directory]::GetFiles($_,$Filter)).Count
    Catch [UnauthorizedAccessException] {
    $i = 0
    "{0,-10} {1}" -f $i, $_
    Try{
    $SB_recursive.Invoke($_)
    Catch [UnauthorizedAccessException] {}
    "{0,-10} {1}" -f "Number of files", "Path"
    "{0,-10} {1}" -f "---------------", "----"
    $SB_recursive.Invoke($Path)
    Count-FilesRecursive -Path C:\users -Filter '*.pdf'

  • SOLVED: powershell script working on its own, access denied when called from a service

    Hi powershell experts,
    I'm using a powershell script, called by a service with serviceaccount PWSService, which gives an exception denied. This powershell script sets up a remote powershell connection(with a specific account), and runs some powershell scripts remotely on
    that server. 
    When I launch the powershell script manually, by opening the powershell console myself(with "run as" PWSService), the remote session starts and I'm able to succesfully run commands through it.
    The PWSService is local admin on the server.
    Is there any diffrence in behaviour when powershell scripts are started by a service or started as a "user"? Can someone shed a light on this?
    Thanks in advance,
    Robin
    MCTS, MCPD

    hi mjolinor,
    We use the following class for the service(Microsoft
    live@edu connector):
    http://msdn.microsoft.com/en-us/library/system.management.automation.runspaces.wsmanconnectioninfo%28v=vs.85%29.aspx
    I use Enter-PSSession to start the commands in de powershell console which works.
    MCPD

  • Exclude a KB number from a Windows update Powershell Script.

    I am having a heck of a time removing a patch from the $updates patch collection. We have one that we do not want to install. Using attempts like $updates.remove are not working. Has anyone accomplished this before?
    thanks
    $updateSession = new-object -com "Microsoft.Update.Session"
    Write-Host("Searching for applicable updates...") -Fore Green
    $updates=$updateSession.CreateupdateSearcher().Search($criteria).Updates
    $downloader = $updateSession.CreateUpdateDownloader()         
    $downloader.Updates = $Updates
    foreach ($y in $updates){$y.kbarticleIDs}
    (section to remove a KB from $updates, based on KB)

    Here is a little script that will create a hash table of all applicable updates, and their associated UUID's.  This can be used to look up the UUID, to use as a criteria when searching again:
    $upids = @{}
    $Searcher = New-Object -ComObject Microsoft.Update.Searcher
    $results = $searcher.search("Type='software' AND IsInstalled = 0")
    $Results.Updates |
    ForEach-Object { $upids.Add($_.Title, $_.Identity.UpdateID) }
    $upids
    ([string](0..9|%{[char][int](32+("39826578846355658268").substring(($_*2),2))})).replace(' ','')
    What's new in Powershell 3.0 (Technet Wiki)

  • Script to list the users and their privileges in a database

    Hi Team,
    Can someone provide me a script that list all the users and their privileges in a database?
    DB version:11.2.0.2
    OS:AIX

    Osama_mustafa wrote:
    Why you create your own script
    SELECT * FROM USER_SYS_PRIVS;
    SELECT * FROM USER_TAB_PRIVS;
    SELECT * FROM USER_ROLE_PRIVS;
    That won't tell him what privileges a user has via a role. It will only tell him what privilges were granted directly, and what roles were granted directly. But those roles have privileges, and may have other roles, which have still more roles and privs, etc. It's a recursive issue and a simple select from user__privs won't get it.
    Pete Finnigan has a good script for reporting the entire picture. I leave it as an exercise for the student to use google to find it. I have already given all the information needed to complete that exercise.

Maybe you are looking for

  • Audiobooks going into "Other" folder when syncing on 5th gen video ipod

    Suddenly a bunch of audiobooks I bought recently are not syncing properly. They seem to be going into the "other" category because when I look at my iPod memory summary, the colored bar chart, I see that category (in orange) growing but Audio (blue)

  • Can I use my personal creative cloud at work?

    If I have purchased creative cloud for myself, can I use it on my work computer?

  • How to present results from a sql-query in java

    Hi - I'm having problems finding out how to present data from a database-query in a nice looking way in a JFrame. Want to present them similar to the way they are presented in the database. Is there an easy way doing this?

  • Pointer Tool Click Zones

    These are great and I use them all the time, but I do have a problem with the top and bottom arrangement. Just lately I have been spending a bit more time in Pro tools (hence the multi tool) and have suddenly realised upon jumping back into Logic lan

  • Video input from VHS?

    I have an iBook G4 12" and have a need to get images off of VHS. Not having done this before, I was wondering what the best (and least expensive) means of doing so would be in terms of hardware and software. Many thanks for any ideas, and apologies i