happy Friday all.
is it possible to filter information within brackets from a file and if so how would one going about doing that.
for exp
20015-21-08{12345-6789} oium
and all I want is the "12345-6789"
happy Friday all.
is it possible to filter information within brackets from a file and if so how would one going about doing that.
for exp
20015-21-08{12345-6789} oium
and all I want is the "12345-6789"
Normal 0 false false false EN-AU X-NONE X-NONEHow would I write a powershell script to add an Active Directory Organizational Unit to a Domain?
Hi people! I've hit a bit of a brick wall with a little project I've been working on. The idea was a sort of basic asset tracking system. The plan was to take username and serial number and store them in AD. The locations I was going to use are in the computer account, Location and ManagedBy properties. While the script runs fine as admin, when running as a limited user obviously they don't have permission to update these fields in AD. So, I was thinking of using Delegate Permissions but I can find location or ManagedBy in the delegation wizard.
Anyone able to point me in the right direction or offer a better solution?
Thanks,
Baz
Hello all,
I have two commands that I would like to try and combine. The first command is:
***********
Get-ADGroupMember"Name of your group" | ?{$_.ObjectClass -eq "Group"} | %{Write-Host $_.Name;Get-ADGroupMember $_ | ft name -HideTableHeaders}
************
What this command shows me is the group name and then the display name of the users within all of the directly nested groups. IE:
NestedGroupName1
Anderson, Jake
Jean, Billie
NestedGroupName2
Schlama, dama
Bleh, meh
The second command is:
*************
$var = Read-host 'What is the Group Name?'; Get-ADGroupMember -Identity $var -server domain.com -Credential (Get-Credential -Credential domain\username) | Where-Object { $_.objectClass -eq 'user' } | Get-ADUser -Properties * | select SamAccountName,Description,Department
************
This lists all of the members of a group with the userID, Description, and Department.
What I would like is the recursive property of the first command with the detail from the second command. Can this be done?
Hi there,
I have created a test user called Graham Test
I need to update the Display Name field on certain User Accounts in AD with "(External)" based on whether their Company field has certain titles.
I am okay with picking the user with certain Company names using the following:
$users=Get-ADUser-Filter {(Company-eq"Custard")}-SearchScopeSubtree-SearchBase$ouDomain|Select-ObjectDistinguishedName
But I am struggling with getting it to write the Display Name, all I get so far is the following:
@{surName=Test}, @(givenName=Graham}(External)
and I have no idea where the @ symbols are coming from.
Any ideas what the best way to do this would be.
I can post my script if required.
Thanks for any ideas
Graham
Hello,
I am try to disable a bunch of accounts on a different sub-domain from a CSV file. I've used the same code on the main domain without any issues, so this only fails on "DC=DEV,DC=FABRIKAM,DC=COM". Here is the code I am using:
Get-ADUser -Identity test.user -credential dev.fabrikam.com\ben.admin -searchbase "DC=dev,DC=fabrikam,DC=com"
I've tried isolating the issue by both adding and removing the credential param and by searching for an account I know for sure is on dev.fabrikam.com, but I still get the following error:
Get-ADUser : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Get-ADUser -Identity test.user -credential dev.fabrikam.com\ben.admin -se ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.ActiveDirectory.Management.Commands.GetADUser
Any ideas would be appreciated. Thanks,
Normal 0 false false false EN-AU X-NONE X-NONEHow would I write a powershell script to add an Active Directory Group to an AD Domain?
Hello All i am working on a simple script that will export the contents of an AD group with a couple properties so the groups users can be imported into a new domain i just stood up. Here is the code i have so far:
Example:
Get-ADGroupMember -Identity Administrators | Select-Object Name,SamAccountName,Surname | Export-Csv GroupMembers.csv
In my output i get:
#TYPE Selected.Microsoft.ActiveDirectory.Management.ADPrincipal | ||
Name | SamAccountName | Surname |
Domain Admins | Domain Admins | Microsoft.ActiveDirectory.Management.ADPropertyValueCollection |
Enterprise Admins | Enterprise Admins | Microsoft.ActiveDirectory.Management.ADPropertyValueCollection |
Administrator | Administrator | Microsoft.ActiveDirectory.Management.ADPropertyValueCollection |
I am not quite sure how i export the multi-valued attribute. Any help would be appreciated.
Hello All,
Please help me in powershell to find who added a user to a AD group.
Regards,
Priyabrata
Dear all, How can I get Windows Product Key from Active Directory Users Machine via power shell or any tools? In our company, we have 300 PC. Somehow they lost Windows product keys. So now they want all users machine windows product keys. Is it not possible to go physically all end users and in that case i can't use also key finder software. Company authority assigned me to find a way get windows product key for all machines but I am unable to find this. Any one can help me about this.Thanks in advanced.
Thanks
Hosen
Hello! I need help. I won't to add logged users in computer description.it is a script. Many I can do that more easy? Thank you!!!
$containers = Get-ADComputer -SearchBase "OU=Computers,DC=local" - k "DNSHostName -like '*'" -properties ipv4address
Get-ADUser -SearchBase "OU=Temp,DC=local" -filter * | Foreach {$h = @{}} {$h.Add($_.SamAccountName,$_.Name)}
foreach ($comp in $containers) {
try {
$wmi = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $comp.DNSHostName -Ea Stop
$u = $wmi.UserName.split("\")[1]
$s = $h[$u]
$description = "{0} {1} {2}" -f $u,$s,$comp.ipv4address
Set-ADComputer $comp -Description $description
}
catch {
"$($comp.Name): $_"
}}
I have a script pieced together from other posts that add users to groups based on the OU they reside within.
I would like to get the output of the actions the script have taken but am stuck on how to do this.
The script is ...
$OU="OU=Desktop Users,DC=domain,DC=internal"
$ShadowGroup="CN=GroupName,OU=Security Groups,DC=domain,DC=internal"
Get-ADGroupMember-Identity$ShadowGroup|Where-Object {$_.distinguishedName -NotMatch$OU} |ForEach-Object {Remove-ADPrincipalGroupMembership-Identity$_-MemberOf$ShadowGroup-Confirm:$false}
Get-ADUser-SearchBase$OU-SearchScopeOneLevel-LDAPFilter"(!memberOf=$ShadowGroup)"|ForEach-Object {Add-ADPrincipalGroupMembership-Identity$_-MemberOf$ShadowGroup}
For auditing purposes I need to log the changes that the Remove & Add ADPrincipalGroupMembership have made. Is there an easy way to output this to a file. I tried Write-Output but could not get it to do what I needed.
I have written a script that will update most of the fields that I am looking for, except the Manger field. For the life of me I cannot figure out what I am missing.
Script:
import-module activedirectory
$users = Import-Csv -Path \\<server>\<Folder>\<filename>.csv
foreach ($user in $users) {
$manager = Get-ADUser -Filter "CN -eq '$($users.Manager)'"
Get-ADUser -Filter "DisplayName -eq '$($user.PreferredName)'" -Properties * |
Set-ADUser -employeeID $($user.EMPL_ID) -Company $($user.Location) -Office $($user.Location) -Title $($user.TITLE_DESC) -Department $($user.Department) -Description $($user.TITLE_DESC) -Manager $($manager)
}
It will return no errors, and the other fields will update, however it returns a blank Manger attribute to the AD entry.
The CSV is here:
EMPL_ID,LAST_FIRST_NAME,S_EMPL_STATUS_CD,Manager,Location,PreferredName,TITLE_DESC,Department
3129,"Meehan, Douglas P",ACT,David Yerby,HSAG-AZ,Pete Meehan,Network Administrator 1,Information Technology
I have been combing the technet, spice works and here, but I am still stuck. Please help.
Hi,
I need product keys for Installed Software Adobe products.
I need to collect this information for audit purpose.
thanks
Kabir
Hi All,
I after some guidance on how to remove a bulk amount of accounts. I am using the following command and it works just fine.
Remove-ADUser -Identity "CN=Gail Moss,OU=UserAccounts,DC=XXX,DC=com"
But how i get that to import from a csv and do all the accounts at once? Any assistance would be awesome. I have found example of removing from account name but we require to use DN.
Bests
GR
Hello,
I need to find out which User have which Properties in AD.
For example: User A has Property A and B.
Actually I'm using:
Get-ADUser -Filter {name -like "*"} -Properties MemberOf | fl
and it works but not like I need it. It gives me too much information.
I only need the Name and the proberty, also it would be good to filter if the account is enable or not.
It also should create a excle sheet if this is possible. (I'm new to PowerShell).
Thanks for your help
Hi.
We have had a large organizational change and I have to change security groups and user rights accordingly for the whole organization accordingly.
For that reason I need to list all users MemberOf group starting with "gteam2_*" and have a list showing which recursive groups each "gteam2_*" group is MemberOf.
Example:
User John is MemberOf global security group "gteam2_HumanRessource".
Gteam2_HumanRessource is member of the following groups (mostly local groups but can also be global groups):
RDAT_SHP_HR_Menue
RDAT_SHP_HR_Admins
GFUNK_HR
etc.
I want to have an Output looking like
Groupname;Name;SAMAccountName;Description;Manager (as SamAccountName);NestedGroups
Gteam2_HR;John;John Clease;HR-Department;MAN;RDAT_SHP_HR_Menue
Gteam2_HR;John;John Clease;HR-Department;MAN;RDAT_SHP_HR_Admins
Gteam2_HR;John;John Clease;HR-Department;MAN;GFUNK_HR
So far I have managed to get this Output:
Groupname;SamAccountName;Name
My script looks like this:
____________________________________
Import-Module ActiveDirectory
$server = read-host -prompt 'type domain'
$Groups = (Get-AdGroup -server $server -filter * | Where {$_.name -like "gteam2_*"} | select name -expandproperty name)
$Table = @()
$Record = [ordered]@{
"Group Name" = ""
"Name" = ""
"Username" = ""
}
Foreach ($Group in $Groups)
{
$Arrayofmembers = Get-ADGroupMember -server $server -identity $Group -Recursive | select name,samaccountname
foreach ($Member in $Arrayofmembers)
{
$Record."Group Name" = $Group
$Record."Name" = $Member.name
$Record."UserName" = $Member.samaccountname
$objRecord = New-Object PSObject -property $Record
$Table += $objrecord
}
}
# Output the result to the file groupmemberships.csv
$Path = "C:\users\John\documents\"
# Get the group name, which we'll use to name the HTML File.
$file = $path + $server + '_' + 'Gteam2Members.csv'
$Table | export-csv -path "$file" -NoTypeInformation -Encoding "UTF8"
_____________________
I need the following info in my output/added to my script, but I do not know how:
Description (of SamAccountName)
Manager (listetd as SamAccountName)
Nested groups that gteam_* is a MemberOf
I would be very happy if someone could help me.
Regards Carsten
Normal 0 false false false EN-AU X-NONE X-NONEHow would I write a powershell script to add an Active Directory user to an existing group?
Any examples of a Powershell script to map a network drive?
Hi.
I need to correct 3 AD-attributes in AD for all users so that the numbers will be without spaces and the country code +45 needs to be added on:
a) HomePhone
b) MobilePhone
c) OtherMobile
Example:
Before:
Homephone: xx xx xx xx
MobilePhone: +45 xx xx xx xx
OtherMobile: xxxx xxxx
Wanted result:
Homephone: +45xxxxxxxx
MobilePhone: +45xxxxxxxx
OtherMobile: +45xxxxxxxx
I have tried various things but cannot get it right:
get-aduser -SearchBase "OU=NoAdm,OU=Users,DC=xxxxx,DC=xxxxx,DC=xxxxx,DC=net" -filter * -properties homephone | where { $_.Homephone -ne $_.Homephone.trim() }
I have also tried various commands with -replace '\s+',""
I would appreciate a helping hand!