Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Run Powershell script for all users in Active Directory.

$
0
0

Powershell
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import-moduleActiveDirectory$users=Get-ADUser-Filter'enabled -eq $true'-PropertiesSamAccountName|flSamAccountNameForEach($userin$users){$strName=$user.DisplayName$strTitle=$user.Title$strCompany=$user.Company$strStreet=$user.StreetAddress$strPhone=$user.homePhone$strMainPhone=$user.ipPhone$strMobile=$user.mobile$strCity=$user.l$strState=$user.st$strEmail=$user.mail$strWebsite=$user.wWWHomePage$strDisplayTitle=$user.postofficebox$strDoNotDisplayMobile=$user.pager$strCerts=$user.department$FolderLocation="C:\Signatures"#Stop non employees getting signature.IF($strCompany-ne"Company Architects, Inc."){BREAK}#Creates Signature wth Title and No Mobile/Ext phone numbersIF($strDoNotDisplayMobile-eq"1"-and$strDisplayTitle-eq"1"){$stream=[System.IO.StreamWriter]"$FolderLocation\\$strName.htm"$stream.WriteLine("`"-//W3C//DTD HTML 4.0 Transitional//EN`">")$stream.WriteLine("Signature")$stream.WriteLine("text/css`">")$stream.WriteLine("A:link { COLOR: #0000A0; TEXT-DECORATION: none; font-weight: normal }")$stream.WriteLine("A:visited { COLOR: #0000A0; TEXT-DECORATION: none; font-weight: normal }")$stream.WriteLine("A:active { COLOR: black; TEXT-DECORATION: none }")$stream.WriteLine("A:hover { COLOR: blue; TEXT-DECORATION: none; font-weight: none }")$stream.WriteLine("-->")$stream.WriteLine("")$stream.WriteLine("")$stream.WriteLine("
`"line-height:16px; margin:6px 0; padding:8px 8px 8px 8px; font-family: 'Lucida Sans', Lucida Grande, Verdana, Arial, Sans-Serif; font-size:11px; color:#333333;`">")$stream.WriteLine("`"color:#333333; font-size:15px; color:#00007C; `">$strName $strCerts
"
)$stream.WriteLine("$strTitle
"
)$stream.WriteLine("
"
)$stream.WriteLine("$strCompany
"
)$stream.WriteLine("$strStreet | $strCity, $strState
"
)$stream.WriteLine("office: $strMainPhone
"
)$stream.WriteLine("`"mailto:$strEmail`" style=`"color: #333333`">$strEmail
"
)$stream.WriteLine("`"http://www.Company.com`">$strWebsite
;"
)$stream.WriteLine("
"
)IF($strState-eq"PA"){$stream.WriteLine("`"http://Companyftp.com/Company_EDGE.jpg`">;")}Else{$stream.WriteLine("`"http://Companyftp.com/CompanyIcon.jpg`">;")}$stream.WriteLine("
"
)$stream.WriteLine("`"https://www.facebook.com/CompanyArchitects`">`"1`">Facebook | `"https://twitter.com/CompanyArchitects`">`"1`">Twitter | `"http://www.linkedin.com/company/Company-Architects`">`"1`">LinkedIn
"
)IF($strState-eq"PA"){$stream.WriteLine("`"#333333`"; font size=`"1`"> EDGE studio has merged with Company Architects")$stream.WriteLine("
"
)$stream.close()}Else{$stream.WriteLine("
")$stream.close()}BREAK}IF($strDoNotDisplayMobile-eq"1"){$stream=[System.IO.StreamWriter]"$FolderLocation\\$strName.htm"$stream.WriteLine("`"-//W3C//DTD HTML 4.0 Transitional//EN`">")$stream.WriteLine("Signature")$stream.WriteLine("text/css`">")$stream.WriteLine("A:link { COLOR: #0000A0; TEXT-DECORATION: none; font-weight: normal }")$stream.WriteLine("A:visited { COLOR: #0000A0; TEXT-DECORATION: none; font-weight: normal }")$stream.WriteLine("A:active { COLOR: black; TEXT-DECORATION: none }")$stream.WriteLine("A:hover { COLOR: blue; TEXT-DECORATION: none; font-weight: none }")$stream.WriteLine("-->")$stream.WriteLine("")$stream.WriteLine("")$stream.WriteLine("
`"line-height:16px; margin:6px 0; padding:8px 8px 8px 8px; font-family: 'Lucida Sans', Lucida Grande, Verdana, Arial, Sans-Serif; font-size:11px; color:#333333;`">")$stream.WriteLine("`"color:#333333; font-size:15px; color:#00007C; `">$strName $strCerts
"
)$stream.WriteLine("
"
)$stream.WriteLine("$strCompany
"
)$stream.WriteLine("$strStreet | $strCity, $strState
"
)$stream.WriteLine("office: $strMainPhone
"
)$stream.WriteLine("`"mailto:$strEmail`" style=`"color: #333333`">$strEmail
"
)$stream.WriteLine("`"http://www.Company.com`">$strWebsite
;"
)$stream.WriteLine("
"
)IF($strState-eq"PA"){$stream.WriteLine("`"http://Companyftp.com/Company_EDGE.jpg`">;")}Else{$stream.WriteLine("`"http://Companyftp.com/CompanyIcon.jpg`">;")}$stream.WriteLine("
"
)$stream.WriteLine("`"https://www.facebook.com/CompanyArchitects`">`"1`">Facebook | `"https://twitter.com/CompanyArchitects`">`"1`">Twitter | `"http://www.linkedin.com/company/Company-Architects`">`"1`">LinkedIn
"
)IF($strState-eq"PA"){$stream.WriteLine("`"#333333`"; font size=`"1`"> EDGE studio has merged with Company Architects")$stream.WriteLine("
"
)$stream.close()}Else{$stream.WriteLine("")$stream.close()}BREAK}IF($strDisplayTitle-eq"1")#Create HTML Signature {$stream=[System.IO.StreamWriter]"$FolderLocation\\$strName.htm"$stream.WriteLine("`"-//W3C//DTD HTML 4.0 Transitional//EN`">")$stream.WriteLine("Signature")$stream.WriteLine("text/css`">")$stream.WriteLine("A:link { COLOR: #0000A0; TEXT-DECORATION: none; font-weight: normal }")$stream.WriteLine("A:visited { COLOR: #0000A0; TEXT-DECORATION: none; font-weight: normal }")$stream.WriteLine("A:active { COLOR: black; TEXT-DECORATION: none }")$stream.WriteLine("A:hover { COLOR: blue; TEXT-DECORATION: none; font-weight: none }")$stream.WriteLine("-->")$stream.WriteLine("")$stream.WriteLine("")$stream.WriteLine("
`"line-height:16px; margin:6px 0; padding:8px 8px 8px 8px; font-family: 'Lucida Sans', Lucida Grande, Verdana, Arial, Sans-Serif; font-size:11px; color:#333333;`">")$stream.WriteLine("`"color:#333333; font-size:15px; color:#00007C; `">$strName $strCerts
"
)$stream.WriteLine("$strTitle
"
)$stream.WriteLine("
"
)$stream.WriteLine("$strCompany
"
)$stream.WriteLine("$strStreet | $strCity, $strState
"
)$stream.WriteLine("office: $strMainPhone
"
)$stream.WriteLine("direct: $strPhone
"
)$stream.WriteLine("mobile: $strMobile
"
)$stream.WriteLine("`"mailto:$strEmail`" style=`"color: #333333`">$strEmail
"
)$stream.WriteLine("`"http://www.Company.com`">$strWebsite
;"
)$stream.WriteLine("
"
)IF($strState-eq"PA"){$stream.WriteLine("`"http://Companyftp.com/Company_EDGE.jpg`">;")}Else{$stream.WriteLine("`"http://Companyftp.com/CompanyIcon.jpg`">;")}$stream.WriteLine("
"
)$stream.WriteLine("`"https://www.facebook.com/CompanyArchitects`">`"1`">Facebook | `"https://twitter.com/CompanyArchitects`">`"1`">Twitter | `"http://www.linkedin.com/company/Company-Architects`">`"1`">LinkedIn
"
)IF($strState-eq"PA"){$stream.WriteLine("`"#333333`"; font size=`"1`"> EDGE studio has merged with Company Architects")$stream.WriteLine("
"
)$stream.close()}Else{$stream.WriteLine("")$stream.close()}}Else#Create HTML Signature{$stream=[System.IO.StreamWriter]"$FolderLocation\\$strName.htm"$stream.WriteLine("`"-//W3C//DTD HTML 4.0 Transitional//EN`">")$stream.WriteLine("Signature")$stream.WriteLine("text/css`">")$stream.WriteLine("A:link { COLOR: #0000A0; TEXT-DECORATION: none; font-weight: normal }")$stream.WriteLine("A:visited { COLOR: #0000A0; TEXT-DECORATION: none; font-weight: normal }")$stream.WriteLine("A:active { COLOR: black; TEXT-DECORATION: none }")$stream.WriteLine("A:hover { COLOR: blue; TEXT-DECORATION: none; font-weight: none }")$stream.WriteLine("-->")$stream.WriteLine("")$stream.WriteLine("")$stream.WriteLine("
`"line-height:16px; margin:6px 0; padding:8px 8px 8px 8px; font-family: 'Lucida Sans', Lucida Grande, Verdana, Arial, Sans-Serif; font-size:11px; color:#333333;`">")$stream.WriteLine("`"color:#333333; font-size:15px; color:#00007C; `">$strName $strCerts
"
)$stream.WriteLine("
"
)$stream.WriteLine("$strCompany
"
)$stream.WriteLine("$strStreet | $strCity, $strState
"
)$stream.WriteLine("office: $strMainPhone
"
)$stream.WriteLine("direct: $strPhone
"
)$stream.WriteLine("mobile: $strMobile
"
)$stream.WriteLine("`"mailto:$strEmail`" style=`"color: #333333`">$strEmail
"
)$stream.WriteLine("`"http://www.Company.com`">$strWebsite
;"
)$stream.WriteLine("
"
)IF($strState-eq"PA"){$stream.WriteLine("`"http://Companyftp.com/Company_EDGE.jpg`">;")}Else{$stream.WriteLine("`"http://Companyftp.com/CompanyIcon.jpg`">;")}$stream.WriteLine("
"
)$stream.WriteLine("`"https://www.facebook.com/CompanyArchitects`">`"1`">Facebook | `"https://twitter.com/CompanyArchitects`">`"1`">Twitter | `"http://www.linkedin.com/company/Company-Architects`">`"1`">LinkedIn
"
)IF($strState-eq"PA"){$stream.WriteLine("`"#333333`"; font size=`"1`"> EDGE studio has merged with Company Architects")$stream.WriteLine("
"
)$stream.close()}Else{$stream.WriteLine("")$stream.close()}}}
I am really new to Powershell and still trying to figure this out. What I am trying to do is get the powershell script to run on every account in Active Directory that is active. I run the script but I don't get any errors but also don't get the signature files. Any idea's what I am doing wrong?


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>