Jump to content

Recommended Posts

  • 2 months later...
Posted

For those trying to use the script themselves I have created a video to help:

 

 

I am also working on a little update that sorts a few things out.

  • Thanks 2
  • 3 months later...
  • 1 month later...
Posted

Hi, I've got this working on a test machine. It's simple once someone has done all the work for you [emoji846].

 

But I was wondering, is it possible to do this with AAD as we are looking at moving our Staff devices over to Intune.

Posted
Hi, I've got this working on a test machine. It's simple once someone has done all the work for you [emoji846].

But I was wondering, is it possible to do this with AAD as we are looking at moving our Staff devices over to Intune.

Hello there,

 

Are you keeping your on premise AD or moving purely to AAD?

 

Thank you :)

Posted
Hi @qweetyMash, for the foreseeable, we'd be keeping on prem AD, but the devices wouldn't be domain joined.

Hmm not sure what the best way to go about it would be as to get the details from azure AD they would need powershell modules and stuff.

  • 2 months later...
Posted

Been doing more work this project. Coming this weekend if time permits.

A second script which can be used to set Outlook Web Signatures that also use the information from active directory etc.

 

Is it possible for me to edit my first post to update it? Or can Admins help me edit the first post?

 

The script and output has been updated many times since my original post and it would be nice if I could update the original post with more up to date information such as a link to the YouTube video I made helping with the setup of this script etc.

  • 5 months later...
Posted

Thank you so much for sharing this script.

I have modified it and it is working well; but I was wondering if there was a way of adding the fax number to the output.

I have tried adding an extra line for if($user.fax.count -gt 0){$fax = $user.faxnumber[0]} using both ‘fax’ and ‘facsimileTelephoneNumber’ as listed using an get-aduser lookup; but the there is nothing in the output to the signature.

Can a fax number be added, and do you know what I am missing?

Thanks again.

Posted
Thank you so much for sharing this script.

I have modified it and it is working well; but I was wondering if there was a way of adding the fax number to the output.

I have tried adding an extra line for if($user.fax.count -gt 0){$fax = $user.faxnumber[0]} using both ‘fax’ and ‘facsimileTelephoneNumber’ as listed using an get-aduser lookup; but the there is nothing in the output to the signature.

Can a fax number be added, and do you know what I am missing?

Thanks again.

 

That code you posted wouldn't be right. The count should be the same item as the [0]

 

So if you're using fax as an example@

 

if($user.fax.count -gt 0){$faxnumber = $user.fax[0]}

As you're checking if fax exists and if so assigned fax to your variable (or same with facsimile etc)

 

Steve

  • Thanks 1
Posted

Thanks for the reply, and sorry I copied the incorrect code.

Please put it down to frustration and lack of sleep.

 

The code i am currently running is

 

if($user.Fax.count -gt 0){$faxnumber = $user.Fax[0]}

and

$(if($faxnumber){"F: $($faxnumber)"})

 

I have removed the 'if' statement from the Building HTML section and the text shows; but not the fax number.

Thanks again,

Peter Digby

Posted

Just tested that on some actual live data, and seems the code works but it has to use the full name version (It doesn't return data under Fax for me, only facsimiletelephonenumber):

$user = (([adsisearcher]"(&(objectCategory=User)(samaccountname=$env:username))").FindOne().Properties)
if($user.facsimiletelephonenumber.count -gt 0){$faxnumber = $user.facsimiletelephonenumber[0]}
$(if($faxnumber){"F: $($faxnumber)"})

 

Returns data for me:

F: FaxTest123456

 

Steve

  • Thanks 1
  • 2 weeks later...
Posted

(Hopefully) one final question.

Is it possible to have more than one 'Group Check' for different departments?

 

Currently using the Group Check for the IT Department with the modified code of

$Group = [ADSI]"LDAP://OU=Information Technology,OU=domain"  
$Group.Member | ForEach-Object { 
if ($user.distinguishedname -match $_) {        
$ItStaff = $true
}
}

and

$(if($ITStaff){"IT Helpdesk"+" |"})

and it is working as expected.

 

I have tried setting up a second Group Check with the following; but it includes both the IT and HR details.

 

$Group2 = [ADSI]"LDAP://cn=HR,OU=domain"  $Group2.Member | ForEach-Object {
 if ($user.distinguishedname -match $_) {
 $HRStaff = $true
} 
}

and

$(if($HRStaff){"Human Resources"+" |"})

 

Is there a way to have the script check multiple departments; but only add the specific info for each department?

 

Thanks again,

Peter Digby

Posted
That should be straightforward to do, quick question - are you checking the Parent OU of the user for the IT Staff but checking if the user is in a security group for the HR staff?
  • Thanks 1
Posted (edited)

$list = @{
   "GDPR.Champions" = "[email protected]"
   "Staff" =  "[email protected]"
}
$email=@()
$user = Get-ADUser test.user -pro MemberOf
$group = $user.MemberOf -replace '^CN=([^,]+),OU=.+$','$1'
$group | %{$email += $list[$_]}

$dn = $user.DistinguishedName.Split(",")[2] -replace "OU="
$email += $list[$dn]$email

 

Get the user and their groups.

Get the name of the groups using rexexp to get the text between CN= and ,OU=

For each of the groups the user is a member of add the value of the hashtable to the email array

 

Then do the same thing, but with the first OU that they are part of.

 

 

GDPR.Champ is the name of a group

Staff is the name of an OU

Edited by DaveTheTech
  • Thanks 1
Posted

Thank you for pointing me in the right direction of checking for the AD group.

The AD group i was using had been moved into a sub-OU, causing the issue.

Once i had the correct path to the security group, everything worked as required.

 

If anyone else needs the full code, it is

 

 

# Group Check  
$Group = [ADSI]"LDAP://cn=IT Alerts,OU=Groups,OU=domain"  
 $Group.Member | ForEach-Object {
 if ($user.distinguishedname -match $_) {
 $ItStaff = $true
 }
 } 

$Group = [ADSI]"LDAP://cn=Human Resources,OU=Groups,OU=domain"  
 $Group.Member | ForEach-Object {
 if ($user.distinguishedname -match $_) {
 $HRStaff = $true
 }
 }

 

and in the signature generation area

 

$(if($ITStaff){"IT Helpdesk"+" |"})

$(if($HRStaff){"Human Resources"+" |"})

 

Thanks again.

Peter Digby

  • Thanks 1
  • 3 months later...
Posted

Hi @QwertyMash, firstly excellent work with the scripts!

 

I don't know if you could help, I'm trying to add a font reference and stylesheet reference for social media icons above the

 

Is this support in Outlook as other sources seem to suggest it should be possible?

 

 

 

Also I'm trying to pull in the display name AD attribute , is this the correct reference as its not returning anything.

 

if($user.displayName.count -gt 0){$displayName = $user.displayName[0]}

Posted

Hello,

 

Sorry the delay, for some reason the email about the response went into my junk.

When I get back home I will take a look at your post properly and hopefully be able to help :) Just running a few errands first.

 

Thank you.

Posted (edited)
Hello,

 

Sorry the delay, for some reason the email about the response went into my junk.

When I get back home I will take a look at your post properly and hopefully be able to help :) Just running a few errands first.

 

Thank you.

 

No worry @QwertyMash I think I have answered my first question as a flat no its not supported looking at a couple of sources.

 

Also fixed my second issues, cAse sEnsitive :D

Edited by RobFuller
  • Thanks 1
Posted
No worry @QwertyMash I think I have answered my first question as a flat no its not supported looking at a couple of sources.

 

Also fixed my second issues, cAse sEnsitive :D

 

I am glad to hear you fixed your issue, I was just typing that it is case sensitive when I saw that you had posted again haha.

  • Thanks 1
  • 4 months later...
Posted

Can I ask a question about this script, I have 99% of it working the way I want to, but adjusting the plain text, How can I get it to show no-standard txt? IE, in the HTML Code I have:

Mit freundlichen Grüßen - Best Regards - which comes out as Mit freundlichen Grüßen - Best Regards

 

This is perfect, but when I try putting this into plain text, I get

Mit freundlichen Gr??en - Best Regards - I have tried copying the correct code (Grüßen) and just the Grüßen but it still shows as ??

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...