Search the Community
Showing results for tags 'powershell'.
-
Hello, We have recently had our safeguarding officer request to be CCd into emails sent to certain 'dynamic' distribution groups. They are dynamic based on attributes in active directory. For example IF 'Company' IS 'Intake 2014' which is used for Year 7's. This is the same for each year group. As they all use the same attribute 'Company' the safeguarding officer could only be added to one year group. I have had a look at creating a global rule under mail flow where the recipient is the year groups cc the safeguarding officer but get an error error SentTo predicate does not allow distribution groups. Does anyone know a way I can attach a single user to multiple dynamic distribution groups? Thank you, William
- 4 replies
-
- distribution group
-
(and 2 more)
Tagged with:
-
I am in the midst of developing a Powershell script from an original I found on the web to cater to my colleagues needs. We currently use a VBS script developed by some colleagues who no longer work with us in conjunction with a spreadsheet of users. I am looking to reduce the amount of information required in this spreadsheet and ultimately reduce the preparation time required for it. In a lot of schools, we have started implementing DFS Namespaces instead of pointing directly to folders on a server. I am wondering if there is any way currently (I know it's going to be featured in Powershell on the new version of Windows Server) of retrieving a DFS namespace so that the script can generate the path for user's profile and home folder itself? The original script adds the user and moves it to the relevant OU. My additions include actually creating the user's home and profile folders and applied permissions. My next step is to reduce the total time from obtaining the list of new users to them being fully uploaded to AD which is where my thinking of generating paths automatically came from. I have tested what I have done so far on Server 2008R2 and 2012 and 2012R2 and it's good so far. I'd appreciate any ideas or if you need anymore info from me let me know! NOTE: I am a complete newbie to powershell and I appreciate there may already be scripts out there that can do what I want, I learn better by doing it myself then trying to decipher someone else's code
- 2 replies
-
- active directory
- create user
-
(and 3 more)
Tagged with:
-
Hi all Does anyone have a link to the quest AD cmdlets? I've looked everywhere but I can't find anything, any help would be much appreciated. Many thanks Phil
-
Hi, I am looking for a script to check an email account and extract all attachments to a network share? Has anyone please by any chance already got or seen anything like this? My initial searches led me to the "Get-IMAP" command and then... Get-IMAP -AttachmentDirectory "C:\temp\Attachments" -User $user -Password $password -Mailbox INBOX -Server $server -view $msgId But im hoping not to have to re-invent the wheel if someone already does this! Thanks in advance
-
Brand new version released yesterday. Website / Download / Previous Thread Tagging @Geoff, @garethedmondson
- 2 replies
-
- 3
-
-
- application deployment
- powershell
-
(and 1 more)
Tagged with:
-
So first intake with the new exchange server, unlike the old 2007 I can't bulk select 117 users and click create mailbox. Now I have to use the superior powershell method! or do it 1 at a time Enable-Mailbox [email protected] -Database "Mailbox Database 0768102315" This command works great is simple and clear! Now how to use it with the other 116 pupils? I'm thinking I need to tell it to look at a csv how do I do this. I think that the CSV only needs the upn in it. Examples on line seem to include unnecessary details in the CSV and use them in the script? SIDENOTE: This is the first step I'll migrate to o365 later. (if I give the pupils emails from within o365, although they work the local exchange server is unaware of them, I worry what that may mean in the future.) Hybrid.
-
Hi guys, Has anyone managed to successfully archive Teams in bulk? Our SMT have decided that they'd like to archive all Teams (around 600) however on Microsoft's documentation I can only find a GUI option (one by one). If so, I'd be very grateful for some tips Thank you! A
- 9 replies
-
- archive
- powershell
-
(and 1 more)
Tagged with:
-
Hi guys, I've been scraping by with PowerShell and Teams however I can't seem to find a reference for the PowerShell Policy types. Here's what I know so far: -PolicyType [b]TeamsMeetingPolicy[/b] -PolicyName Education_SecondaryStudent -PolicyType [b]TeamsMessagingPolicy[/b] -PolicyName Education_SecondaryStudent -PolicyType [b]TeamsAppPermissionPolicy[/b] -PolicyName Education_SecondaryStudent [color=#ff0000][/color]-PolicyType [b]TeamsAppSetupPolicy[/b] -PolicyName Education_SecondaryStudent -PolicyType [b]TeamsCallingPolicy[/b] -PolicyName Education_SecondaryStudent I just wondered if anyone knew the full list of names for Policy Types in Teams PowerShell? Thanks! A
-
- policy
- powershell
-
(and 1 more)
Tagged with:
-
Hi All, I'm pretty new to Powershell and I find myself struggling to do something that is probably pretty basic. I have a list of student names and email addresses on a CSV. I need to use that information to extract the sam account names from AD so I can then run another script to set all the students' passwords. The csv has headers Name,Year,Group,Firstname,Surname,Email I've tried this: Import-csv C:\list.csv |foreach-object {$mail = $_."email"get-aduser -filter {mail -eq $mail} select-object name, samaccountname, mail |export-csv c:\logonids.csv -Append -Encoding UTF8} Whenever I run it I get a list of each username appear on screen. About halfway thru this pops up: get-aduser : The search filter cannot be recognizedAt line:4 char:1+ get-aduser -filter {mail -eq $mail}+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: ( [Get-ADUser], ADException + FullyQualifiedErrorId : ActiveDirectoryServer:8254,Microsoft.ActiveDirectory.Management.Commands.GetADUser The output file is created but, needless to say, is empty. I really don't know what I am doing Any help??
-
SharedPC - Powershell to check if provisioning package is installed
HCC posted a topic in Windows 10
Hey, I'm trying to enable SharedPC mode on the W10 student PCs to improve logon times. Does anyone have a powershell script that checks if a Provisioning package is installed, and installs if its missing? or another way I did think about is group policy and the MDM bridge, or via intune. Background: I've manually installed a PPKG on a few test PCs to enable SharedPC to try to improve logon times over the mandatory profile we have now. We have moved all student files to OneDrive so intend to use KFM with silent SSO (and I know SharedPC has a OneDrive sync client issue, but I think I've added an GP to override that to allow it to run). -
Hi guys and gals, Has anyone successfully managed to deploy mapped network drives/enabled UNC paths using Intune? The closest I have come is to deploy a PowerShell script however it doesn't appear to work. I can enable the UNC path when I run the command below locally on the device, but I'm not seeing the same result with the Intune PowerShell script. Intune is telling me that the script was deployed successfully to the device but I've not seen any evidence to support that. net use \\\ password /user:domain\user /persistent:yes Any tips would be awesome! Thanks! Best wishes, A
- 1 reply
-
- intune
- intune for education
-
(and 1 more)
Tagged with:
-
Hope someone can help me out as I'm hitting brick wall and it doesn't help my powershell knowledge is vary limited; I'm looking to import a list of users to multiple teams, idealy from CSV file (2 sperate list either one CSV or 2 CSV), but I'm getting few issues; I can't tell the script to read the two lists seperatly (either from 1 CSV File or 2 CSV files), it reads each row as a single line Only ways I can get it working is either add list of users one team at a time by editing the line to specifically state what group ID or using visual basic input box prompting the user to enter in username and then adding that user to list of teams (not bad for one offs etc.) I thought about using a double for each (nesting I think it's called?) but that doesn't work as stated above it reads the row data as a single line, or i can't figure out how tell the script; for this group add the list of users, next group and add the list of users etc. sorry if my explination is confusing, mix of tired and dylexia.
-
Job Title: Support Engineer Apprentice Apprentice Course: QA Infrastructure Technician Programme or Developer Programme Who are we? We are a Microsoft Partner that specialises in creating engaging innovative solutions for SharePoint and Office 365. Our passion is to enhance the classroom and workplace with technology that delivers real benefits to schools and businesses. As our customer base is growing, we are looking for a support technician to help us maintain our level of support to our new and existing customers. We pride ourselves on being at the cutting-edge of SharePoint solutions in the world education market with customers in the UK and abroad. We help our customers and the wider community through blogs, open source software and YouTube video guides. What we need you to do: You will be joining the team to help us remotely install and support our range of SharePoint MIS integration products into schools. The main products you will be working with are our range of integration products, linking the school MIS to SharePoint and Office 365. Our work is conducted from our office in Hull, although some occasional travel and hotel stay may be needed to allow us to meet as a team and best support our customers. During the pandemic we are working from home so you will need a reliable broadband connection and a quiet place to work. Your day-to-day duties will include: · Remotely supporting customers · Analysing data and manipulating it through workflows · Taking calls on the support desk · Problem solving server and software issues · Creating video tutorials · Any other duties as may be reasonably required by the purview of the post. The successful candidate will learn and use the following software through experience, guidance and self-learning: · SharePoint and Office 365 · Visual Studio Code · TeamViewer · Notepad ++ · PowerShell · Our internal software We are looking for someone with great communication and technical skills. This is a customer facing role and you will be required to contact customers and colleagues via phone, Teams and email. You will strive for perfection and a project will only be finished when our customers are happy with the end-product. Office 365 is constantly evolving, and you will need to be a quick learner with a passion for technology. Key candidate attributes: · Keen and willing to learn through research and practice · Someone who has a passion or at least an interest in the industry · Excellent attention to detail, ability to follow instructions Required: · Excellent written and verbal communication skills · Skills in problem solving, organisation and planning Salary: Above min wage depending on experience. Hours: 37.5 hours per week (Monday to Friday, 8.30am – 5pm) **APPROVED**
-
- apprentice
- data analyst
-
(and 3 more)
Tagged with:
-
Hello, Hoping someone can help with the below script? Were moving to SCCM over Summer and I'm getting our Applications ready now. Creating an application for Office 2016 was easy enough except for the activation. I've had to create a PowerShell script to run afterwards that looks like this: if ((gwmi win32_operatingsystem | select osarchitecture).osarchitecture -eq "64-bit") {Write-Host "64 Bit OS Detected - Running 64 Bit Activation"& "C:\Windows\system32\cscript.exe" "C:\Program Files (x86)\microsoft office\office16\ospp.vbs" /inpkey:XXXXX-YYYYY-ZZZZZ-AAAAA-BBBBB& "C:\Windows\system32\cscript.exe" "C:\Program Files (x86)\microsoft office\office16\ospp.vbs" /act}if ((gwmi win32_operatingsystem | select osarchitecture).osarchitecture -eq "32-bit") {Write-Host "32 Bit OS Detected - Running 32 Bit Activation"& "C:\Windows\system32\cscript.exe" "C:\Program Files\microsoft office\office16\ospp.vbs" /inpkey:XXXXX-YYYYY-ZZZZZ-AAAAA-BBBBB& "C:\Windows\system32\cscript.exe" "C:\Program Files\microsoft office\office16\ospp.vbs" /act}exit It looks to activate fine but I am trying to sort the installation success detection now. I have been trying to do this based on the output of the ospp.vbs /dstatus command. There is a line that shows LICENSE STATUS: ---LICENSED--- I am using the following code to try and extract this line but it always returns a failure, can someone tweak the line below so that I can use this as a success mechanism? if (((& C:\Windows\System32\cscript.exe "C:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs" /dstatus) | Select-String -Pattern "LICENSE STATUS:") -contains "-LICENSED-") {Write-Host "Rule Matches"} ELSE {Write-Host "Not Detected"} Ignore the Write-Host command, I am going to change this to Write-Event and check the event viewer for the success status. Hopefully that makes sense. I am new to SCCM so if there is an easier way to do this any help would be great. Thanks.
- 6 replies
-
- office activation
- powershell
-
(and 1 more)
Tagged with:
-
Hi all, LTL FTP etc etc. I'm getting out of the education IT game soon, so I unfortunately won't get to finish this PowerShell module I've been working on to allow changes to RM Nameservers for your domain. RM don't document it, but there is an API used by their Connectivity Services site that allows changes to be made to your DNS Records, and your external Firewall. I've not done anything with the Firewall yet, but the authorisation function will work for those API endpoints as well. I had intended on using this to automate internal site certificates using Let's Encrypt, but it should be usable for any changes to your DNS Records. Hopefully this will be of some use to someone else, and I apologise in advance for my lack of comments (I was going to comment once completed but...) RM-DNS.ps1
-
- connectivityservices
- dns
-
(and 1 more)
Tagged with:
-
I need to be able to find all target path locations for applications in a specific folder. For example - we have a specific folder for the start menu and we want to be able to run a command that lists all target paths for each application in the folder so we can see where they point to etc. Is this possible? My Powershell Knowledge is very basic 😂 Thanks!
-
Hi all. Had a breakthrough today. Went full azure, Intune and autopilot last year. All has been good apart from one thing... no native logon script support. We've tried all the janky methods and settled on Task Scheduler for some time, but it's unreliable. Queue last week, I thought 'There must be a better way!' Lo and behold, there is. I've also not seen anyone else try this, not even in obscure forums deep on the internet (I tried everything to find a good method before!) so this may be the first documented method for this and it's also the BEST way hands down. 1. Firstly, you need to configure Logon Scripts in Local Group Policy on a test/admin PC, by going to: User Configuration > Policies > Windows Settings > Scripts. 2. Add all your logon scripts in here, the same way you used to when you managed your site with Group Policy (except locally) then hit apply. 3. Once you manually add those logon scripts via local GP on a test machine, it will create and populate a folder in "C:\Windows\System32" called "GroupPolicy" 4. Copy the entire "GroupPolicy" folder somewhere else. I copied to Desktop and put it into a folder called "LogonScriptsApp" 5. Open the "GroupPolicy" folder you copied off and make sure the scripts you added can be found in "GroupPolicy\User\Scripts\Logon" if not, move them into this folder. 6. If you had to manually add the scripts to the "Logon" folder, navigate to "GroupPolicy\User\Scripts" and open the file "psscripts.ini" 7. Ensure the .ini file is laid out in this format (I have called the scripts "yourscript1" and "yourscript2" for the purpose of the demonstration): [Logon]0CmdLine=yourscript1.ps10Parameters=1CmdLine=yourscript2.ps11Parameters= 8. As you can see, it should just say CmdLine=*scriptname* - if it has a path before the name of the script, it's not looking in the "Logon" folder discussed above. It must be looking in the Logon directory because we are going to wrap all of this into a Win32 app. 9. If you need to, once those scripts are copied into the "Logon" folder, edit the .ini file and ensure there isn't a path string before the script name and then save the .ini file. 10. Now, you need to make a PowerShell script that will copy all the files from the script root into the "Windows\System32" folder and create/replace the "GroupPolicy" folder and all it's contents, taking ownership of it and setting permissions to allow the file replace to take place. Here is the script below I used to do this, you can copy this exactly as is: # Take ownership and set full control permissions for 'Everyone' on the GroupPolicy folder$destinationFolder = "$env:windir\System32\GroupPolicy"takeown /f $destinationFolder /r /d yicacls $destinationFolder /grant Everyone:(OI)(CI)F /t# Define the source folder based on the script's location$sourceFolder = Join-Path -Path $PSScriptRoot -ChildPath "GroupPolicy"# Use robocopy to mirror the directory structure and files, replacing the destination contentsrobocopy $sourceFolder $destinationFolder /MIR /COPYALL /R:5 /W:1$GroupPolicyFolder = "C:\Windows\System32\GroupPolicy"$acl = Get-Acl $GroupPolicyFolder$perms = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone","FullControl","Allow")$acl.SetAccessRule($perms)$perms = New-Object System.Security.AccessControl.FileSystemAccessRule("Administrators","FullControl","Allow")$acl.SetAccessRule($perms)$perms = New-Object System.Security.AccessControl.FileSystemAccessRule("SYSTEM","FullControl","Allow")$acl.SetAccessRule($perms)Set-Acl $GroupPolicyFolder $acl 11. Save this script as "install.ps1" and put it into the "LogonScriptsApp" folder on the Desktop (Which should also contain the copied off "GroupPolicy" folder and all it's contents as discussed earlier) 12. Now use the win32 app packaging tool to package the app. The source folder is the "LogonScriptsApp" folder on the Desktop and the setup file is the script we just saved as "install.ps1" 13. Upload the new app to Intune, name it etc. and then use this for the install command: %windir%\Sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "install.ps1" This is super important because if you don't run PowerShell from the "sysnative" directory, the script will run and move the files into the SysWOW64 folder instead of System32 because of file redirection restrictions in Windows. 14. Ensure you deploy in system context and not user and also in the 64 bit context, then use one of the script files in the "Logon" folder as the detection rule. 15. You will now have fully native logon scripts using local GP on every machine you deploy to. This method simply uses the native logon scripts functionality from Local Group Policy/Group Policy and so is very reliable. So far, for us it has worked every single time. I really hope this helps somebody and if you have any questions please ask.
- 21 replies
-
- 5
-
-
- intune
- intune logon scripts
-
(and 3 more)
Tagged with:
-
Hi There, I have been asked to create 582 External contacts in office 365. Once i have created the contacts in office 365 i will then move them to a group so the headteacher can email everyone at once. I know this can be done using powershell but I can't seem to get it right. If there any powershell wizards on here that can help me to import the contacts via CSV file onto office 365. P.S - I have already created the CSV File with 2 contacts to test for the time being and i have he required fields. "ExternalEmailAddress" , "Name" , "FirstName" , "Last Name" Thank-you in advance.
-
Hi All, I've been trying to get a Power Shell script to gather a particular event log from a list of remote computers, but as yet not had much success. The script should query a list of PCs in c:\Scripts\server.txt and gather the "Operational" event log with ID 100 (i'm trying to get the boot up and login times on remote computers) Script looks like: $servers=get-content c:\scripts\servers.txt $date=(Get-Date).AddDays(-7) foreach ($server in $servers) { if (test-connection $server -quiet) { $arr1+=get-eventlog -logname Operational -entryType "Warning" -cn $server -after $date | ?{$_.eventid -eq "100" } | select MachineName,EventID,EntryType,Message } if ($arr1) {$arr1 | export-csv c:\scripts\sysoutput.csv -notypeinformation} else {"No matching system log events found..."} } But keeps returning the "no event logs found". Can anyone point me in the right direction please? Thanks for any help. J.
- 9 replies
-
- boot up times
- event logs
-
(and 1 more)
Tagged with:
-
Hi All, I'd like to perform database application transactional and concurrent load testing which requires approx. 100 IP address in a single host (Windows Server 2003 box) so that one NIC can have multiple IP address. Is there any quick way (Powershell / NetSH) to create those IP address in one single box ? example: VM-Simulator1 - 10.2.1.1 10.2.1.2 10.2.1.3 10.2.1.4 10.2.1.5 . . . 10.2.1.102 VM-Simulator2 - 10.2.2.1 10.2.2.2 10.2.2.3 10.2.2.4 10.2.2.5 . . . 10.2.2.102 i know how to do it in Windows Server 2003 manually one by one but that's too daunting to do it manually. Thanks.
- 2 replies
-
- powershell
- vmware
-
(and 1 more)
Tagged with:
-
Hi All, I've got several hundreds of Windows Server 2003 and 2008 virtual machine + several physical machine which is updated by WSUS automatically but it needs to be restarted manually. Is there any way to know which server needs restart and which one is not ?( eg using powershell) Thanks
-
Hi All, What should be the configuration of Exchange Server Message tracking log ? Get-ExchangeServer | where {$_.isHubTransportServer -eq $true} | Get-TransportServer | select Name, *MessageTracking* | ft -AutoSize from the powershell above result here's the result: Name MessageTrackingLogEnabled MessageTrackingLogMaxAge MessageTrackingLogMaxDirectorySize MessageTrackingLogMaxFileSize MessageTrackingLogPat h ---- ------------------------- ------------------------ ---------------------------------- ----------------------------- --------------------- ExHTServer1 True 20.00:00:00 250MB 10MB D:\Program Files\M... ExHTServer2 True 20.00:00:00 250MB 10MB D:\Program Files\M... ExHTServer3 True 20.00:00:00 250MB 10MB D:\Program Files\M... what is the best practice if I want to have a retention of let say 6 months ? I'm confused which parameter that is should/can be changes. Thanks
-
Greetings everyone, How do you organize or implement monitoring system in your domain to monitor these critical error on your workstations and servers ? Hardware Related Error: 7, 9, 11, 51, 52, 55 Potential HD related issue 1053 Servers too hot. Sometimes our Air conditioning breaks. Any kind of help and comments will be greatly apprecaited. Thanks, AWT
- 7 replies
-
- event id
- monitioring
-
(and 1 more)
Tagged with:
-
I use this script modiefied by thescareface to set Outlook signature for all our users, but I want the Reply/forward signature to be something else then the standard signature.. In reply/forward I want the signature to only have: Best Reagards FullName LastName Title Company name While all new mails should have: Best Regards FullName LastName Title Company address P.o.box etc etc How can I modify the script to handle this feature? ###########################################################################" # # Our script # ###########################################################################" #Custom variables $CompanyName = 'ourcompany' $DomainName = 'our.domain.local' $SigSource = "\\our.domain.local\sig_files\$CompanyName" $ForceSignatureNew = '1' #When the signature are forced the signature are enforced as default signature for new messages the next time the script runs. 0 = no force, 1 = force $ForceSignatureReplyForward = '0' #When the signature are forced the signature are enforced as default signature for reply/forward messages the next time the script runs. 0 = no force, 1 = force #Environment variables $AppData=(Get-Item env:appdata).value $SigPath = '\Microsoft\Signatures' $LocalSignaturePath = $AppData+$SigPath $RemoteSignaturePathFull = $SigSource+'\'+$CompanyName+'.docx' #Get Active Directory information for current user $UserName = $env:username $Filter = "(&(objectCategory=User)(samAccountName=$UserName))" $Searcher = New-Object System.DirectoryServices.DirectorySearcher $Searcher.Filter = $Filter $ADUserPath = $Searcher.FindOne() $ADUser = $ADUserPath.GetDirectoryEntry() $ADFirstName = $ADUser.FirstName $ADLastName = $ADUser.LastName $ADTitle = $ADUser.title $ADhomephone = $ADUser.homephone $ADmobile = $ADUser.mobile #Setting registry information for the current user $CompanyRegPath = "HKCU:\Software\"+$CompanyName if (Test-Path $CompanyRegPath) {} else {New-Item -path "HKCU:\Software" -name $CompanyName} if (Test-Path $CompanyRegPath'\Outlook Signature Settings') {} else {New-Item -path $CompanyRegPath -name "Outlook Signature Settings"} $SigVersion = (gci $RemoteSignaturePathFull).LastWriteTime #When was the last time the signature was written $ForcedSignatureNew = (Get-ItemProperty $CompanyRegPath'\Outlook Signature Settings').ForcedSignatureNew $ForcedSignatureReplyForward = (Get-ItemProperty $CompanyRegPath'\Outlook Signature Settings').ForcedSignatureReplyForward $SignatureVersion = (Get-ItemProperty $CompanyRegPath'\Outlook Signature Settings').SignatureVersion Set-ItemProperty $CompanyRegPath'\Outlook Signature Settings' -name SignatureSourceFiles -Value $SigSource $SignatureSourceFiles = (Get-ItemProperty $CompanyRegPath'\Outlook Signature Settings').SignatureSourceFiles #Forcing signature for new messages if enabled if ($ForcedSignatureNew -eq '1') { #Set company signature as default for New messages $MSWord = New-Object -com word.application $EmailOptions = $MSWord.EmailOptions $EmailSignature = $EmailOptions.EmailSignature $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries $EmailSignature.NewMessageSignature=$CompanyName $MSWord.Quit() } #Forcing signature for reply/forward messages if enabled if ($ForcedSignatureReplyForward -eq '1') { #Set company signature as default for Reply/Forward messages $MSWord = New-Object -com word.application $EmailOptions = $MSWord.EmailOptions $EmailSignature = $EmailOptions.EmailSignature $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries $EmailSignature.ReplyMessageSignature=$CompanyName $MSWord.Quit() } #Copying signature sourcefiles and creating signature if signature-version are different from local version if ($SignatureVersion -eq $SigVersion){} else { #Copy signature templates from domain to local Signature-folder Copy-Item "$SignatureSourceFiles\*" $LocalSignaturePath -Recurse -Force $ReplaceAll = 2 $FindContinue = 1 $MatchCase = $True $MatchWholeWord = $Talse $MatchWildcards = $False $MatchSoundsLike = $False $MatchAllWordForms = $False $Forward = $True $Wrap = $FindContinue $Format = $False #Insert variables from Active Directory to rtf signature-file $MSWord = New-Object -com word.application $fullPath = $LocalSignaturePath+'\'+$CompanyName+'.docx' $MSWord.Documents.Open($fullPath) $FindText = "FirstName" $ReplaceText = $ADFirstName.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $FindText = "LastName" $ReplaceText = $ADLastName.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $FindText = "Title" $ReplaceText = $ADTitle.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $FindText = "homephone" $ReplaceText = $ADhomephone.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $FindText = "svgmobile" $ReplaceText = $ADmobile.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatHTML"); $path = $LocalSignaturePath+'\'+$CompanyName+".htm" $MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat) $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatRTF"); $path = $LocalSignaturePath+'\'+$CompanyName+".rtf" $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat) $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatText"); $path = $LocalSignaturePath+'\'+$CompanyName+".txt" $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat) $MSWord.ActiveDocument.Close() $MSWord.Quit() } #Stamp registry-values for Outlook Signature Settings if they doesn`t match the initial script variables. Note that these will apply after the second script run when changes are made in the "Custom variables"-section. if ($ForcedSignatureNew -eq $ForceSignatureNew){} else {Set-ItemProperty $CompanyRegPath'\Outlook Signature Settings' -name ForcedSignatureNew -Value $ForceSignatureNew} if ($ForcedSignatureReplyForward -eq $ForceSignatureReplyForward){} else {Set-ItemProperty $CompanyRegPath'\Outlook Signature Settings' -name ForcedSignatureReplyForward -Value $ForceSignatureReplyForward} if ($SignatureVersion -eq $SigVersion){} else {Set-ItemProperty $CompanyRegPath'\Outlook Signature Settings' -name SignatureVersion -Value $SigVersion}
