├── README.md ├── Properties └── AssemblyInfo.cs ├── LICENSE.md ├── WMIProvider.cs ├── WMIProvider.resx ├── WMIProvider.csproj └── BuildProcessTemplates ├── UpgradeTemplate.xaml ├── LabDefaultTemplate.11.xaml └── DefaultTemplate.11.1.xaml /README.md: -------------------------------------------------------------------------------- 1 | # LocalAdmins 2 | WMI Provider to report all members of the local Administrators group in the WMI Class root\cimv2\Win32_LocalAdmins 3 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("LocalAdmin WMIProvider")] 8 | [assembly: AssemblyDescription("Report local administrators in Win32_LocalAdmins")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Zander Tools")] 11 | [assembly: AssemblyProduct("WMIProvider")] 12 | [assembly: AssemblyCopyright("(c) 2020 by Roger Zander")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | // Setting ComVisible to false makes the types in this assembly not visible 16 | // to COM components. If you need to access a type in this assembly from 17 | // COM, set the ComVisible attribute to true on that type. 18 | [assembly: ComVisible(false)] 19 | // The following GUID is for the ID of the typelib if this project is exposed to COM 20 | [assembly: Guid("8909009f-340d-4c4c-93d3-c8a96584f633")] 21 | // Version information for an assembly consists of the following four values: 22 | // 23 | // Major Version 24 | // Minor Version 25 | // Build Number 26 | // Revision 27 | // 28 | // You can specify all the values or you can default the Build and Revision Numbers 29 | // by using the '*' as shown below: 30 | // [assembly: AssemblyVersion("1.0.*")] 31 | [assembly: AssemblyVersion("1.0.*")] 32 | [assembly: AssemblyFileVersion("1.0.0.5")] 33 | 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Microsoft Public License (Ms-PL) 2 | 3 | This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. 4 | 5 | 1. Definitions 6 | 7 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law. 8 | 9 | A "contribution" is the original software, or any additions or changes to the software. 10 | 11 | A "contributor" is any person that distributes its contribution under this license. 12 | 13 | "Licensed patents" are a contributor's patent claims that read directly on its contribution. 14 | 15 | 2. Grant of Rights 16 | 17 | (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. 18 | 19 | (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. 20 | 21 | 3. Conditions and Limitations 22 | 23 | (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. 24 | 25 | (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. 26 | 27 | (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. 28 | 29 | (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. 30 | 31 | (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. 32 | -------------------------------------------------------------------------------- /WMIProvider.cs: -------------------------------------------------------------------------------- 1 | //LocalAdmin WMI Provider by Roger Zander 2 | 3 | using System; 4 | using System.Collections; 5 | using System.Management.Instrumentation; 6 | using System.DirectoryServices; 7 | using System.Management; 8 | using System.Security.Principal; 9 | 10 | 11 | [assembly: WmiConfiguration(@"root\cimv2", HostingModel = ManagementHostingModel.LocalService)] 12 | namespace LocalAdminWMIProvider 13 | { 14 | [System.ComponentModel.RunInstaller(true)] 15 | public class MyInstall : DefaultManagementInstaller 16 | { 17 | public override void Install(IDictionary stateSaver) 18 | { 19 | base.Install(stateSaver); 20 | System.Runtime.InteropServices.RegistrationServices RS = new System.Runtime.InteropServices.RegistrationServices(); 21 | 22 | try 23 | { 24 | new System.EnterpriseServices.Internal.Publish().GacInstall(System.Reflection.Assembly.GetExecutingAssembly().Location); 25 | } 26 | catch { } 27 | } 28 | 29 | public override void Uninstall(IDictionary savedState) 30 | { 31 | 32 | try 33 | { 34 | ManagementClass MC = new ManagementClass(@"root\cimv2:Win32_LocalAdmins"); 35 | MC.Delete(); 36 | } 37 | catch { } 38 | 39 | try 40 | { 41 | base.Uninstall(savedState); 42 | } 43 | catch { } 44 | 45 | try 46 | { 47 | new System.EnterpriseServices.Internal.Publish().GacRemove(System.Reflection.Assembly.GetExecutingAssembly().Location); 48 | } 49 | catch { } 50 | } 51 | } 52 | 53 | [ManagementEntity(Name = "Win32_LocalAdmins")] 54 | public class LocalAdmins 55 | { 56 | [ManagementKey] 57 | public string Member { get; set; } 58 | 59 | [ManagementProbe] 60 | public string Type { get; set; } 61 | 62 | [ManagementProbe] 63 | public string SID { get; set; } 64 | 65 | /// 66 | /// The Constructor to create new instances of the LocalAdmins class... 67 | /// 68 | public LocalAdmins(string sMember, string sGUID, string sType) 69 | { 70 | Member = sMember; 71 | SID = sGUID; 72 | Type = sType; 73 | } 74 | 75 | /// 76 | /// This Function returns all members of the local Administrators group 77 | /// 78 | /// 79 | [ManagementEnumerator] 80 | static public IEnumerable GetAdmins() 81 | { 82 | //Get the Builtin Administrators Group name based on the SID (S-1-5-32-544) 83 | SecurityIdentifier Sid = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null); 84 | NTAccount LAdmins = (NTAccount)Sid.Translate(typeof(NTAccount)); 85 | 86 | //Enumerate all members of the local Administrators Group 87 | DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + Environment.MachineName + ",Computer"); 88 | DirectoryEntry admGroup = localMachine.Children.Find(LAdmins.Value.Split('\\')[1], "group"); 89 | 90 | foreach (object obj in (IEnumerable)admGroup.Invoke("members", null)) 91 | { 92 | using (DirectoryEntry user = new DirectoryEntry(obj)) 93 | { 94 | string sName = user.Path; 95 | sName = sName.Replace("WinNT://", ""); 96 | if (sName.Contains(Environment.MachineName)) 97 | { 98 | //Remove the Domain Name if it's a local User / Group 99 | sName = sName.Remove(0, sName.LastIndexOf("/") + 1); 100 | } 101 | string sSID = ""; 102 | try 103 | { 104 | //Get the SID from each User/Group 105 | byte[] oSid = user.Properties["objectSid"].Value as byte[]; 106 | SecurityIdentifier SID = new SecurityIdentifier(oSid, 0); 107 | sSID = SID.ToString(); 108 | } 109 | catch { } 110 | 111 | yield return new LocalAdmins(sName, sSID, user.SchemaClassName); 112 | } 113 | } 114 | } 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /WMIProvider.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 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 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | False 122 | 123 | -------------------------------------------------------------------------------- /WMIProvider.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {A69B3398-D392-486A-B914-5AFA61D54E71} 9 | Library 10 | Properties 11 | LocalAdminWMIProvider 12 | LocalAdminWMIProvider 13 | v3.5 14 | 512 15 | true 16 | Key.snk 17 | 18 | 19 | 3.5 20 | 21 | SAK 22 | SAK 23 | SAK 24 | SAK 25 | publish\ 26 | true 27 | Disk 28 | false 29 | Foreground 30 | 7 31 | Days 32 | false 33 | false 34 | true 35 | 0 36 | 1.0.0.%2a 37 | false 38 | false 39 | true 40 | 41 | 42 | true 43 | full 44 | false 45 | bin\Debug\ 46 | DEBUG;TRACE 47 | prompt 48 | 4 49 | AnyCPU 50 | 51 | 52 | pdbonly 53 | true 54 | bin\Release\ 55 | TRACE 56 | prompt 57 | 4 58 | AnyCPU 59 | 60 | 61 | bin\Release_x64\ 62 | TRACE 63 | true 64 | pdbonly 65 | x64 66 | prompt 67 | true 68 | true 69 | true 70 | 71 | 72 | true 73 | bin\x64\Debug\ 74 | DEBUG;TRACE 75 | full 76 | x64 77 | prompt 78 | 79 | 80 | bin\x64\Release\ 81 | TRACE 82 | true 83 | pdbonly 84 | x64 85 | prompt 86 | 87 | 88 | bin\x64\Release_x64\ 89 | TRACE 90 | false 91 | true 92 | false 93 | false 94 | pdbonly 95 | x64 96 | prompt 97 | 98 | 99 | 100 | 101 | 102 | 3.5 103 | False 104 | 105 | 106 | 107 | 108 | 109 | 3.5 110 | False 111 | 112 | 113 | 114 | 115 | 116 | 117 | Component 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | WMIProvider.cs 126 | 127 | 128 | 129 | 130 | False 131 | .NET Framework 3.5 SP1 Client Profile 132 | false 133 | 134 | 135 | False 136 | .NET Framework 3.5 SP1 137 | true 138 | 139 | 140 | False 141 | Windows Installer 3.1 142 | true 143 | 144 | 145 | 146 | 153 | -------------------------------------------------------------------------------- /BuildProcessTemplates/UpgradeTemplate.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | [New Microsoft.TeamFoundation.Build.Workflow.Activities.AgentSettings() With {.MaxWaitTime = New System.TimeSpan(4, 0, 0), .MaxExecutionTime = New System.TimeSpan(0, 0, 0), .TagComparison = Microsoft.TeamFoundation.Build.Workflow.Activities.TagComparison.MatchExactly }] 21 | 22 | 23 | 24 | [Microsoft.TeamFoundation.Build.Workflow.Activities.ToolPlatform.Auto] 25 | [False] 26 | [False] 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | [Microsoft.TeamFoundation.VersionControl.Client.RecursionType.OneLevel] 37 | [Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity.Normal] 38 | 39 | 40 | 41 | All 42 | Assembly references and imported namespaces serialized as XML namespaces 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 | -------------------------------------------------------------------------------- /BuildProcessTemplates/LabDefaultTemplate.11.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 11.0 16 | 17 | 18 | 19 | 20 | 21 | 920,3702 22 | Assembly references and imported namespaces serialized as XML namespaces 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | True 44 | 45 | 46 | 47 | 48 | 49 | 50 | [LabWorkflowParameters.BuildDetails.BuildUri] 51 | 52 | 53 | [ChildBuildDetail.Uri] 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | [BuildLocation] 66 | 67 | 68 | [If(LabWorkflowParameters.BuildDetails.Configuration Is Nothing, BuildLocation, If(LabWorkflowParameters.BuildDetails.Configuration.IsEmpty Or (SelectedBuildDetail.Information.GetNodesByType(Microsoft.TeamFoundation.Build.Common.InformationTypes.ConfigurationSummary, True)).Count = 1, BuildLocation, If(LabWorkflowParameters.BuildDetails.Configuration.IsPlatformEmptyOrAnyCpu, BuildLocation + "\" + LabWorkflowParameters.BuildDetails.Configuration.Configuration, BuildLocation + "\" + LabWorkflowParameters.BuildDetails.Configuration.Platform + "\" + LabWorkflowParameters.BuildDetails.Configuration.Configuration)))] 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | [LabEnvironmentUri] 81 | 82 | 83 | [LabWorkflowParameters.EnvironmentDetails.LabEnvironmentUri.ToString()] 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 | [PostDeploymentSnapshotName] 143 | 144 | 145 | [If(LabWorkflowParameters.BuildDetails.IsTeamSystemBuild = True,String.Format("{0}_{1}_{2}", LabWorkflowParameters.DeploymentDetails.PostDeploymentSnapshotName, BuildNumber,BuildDetail.BuildNumber),String.Format("{0}_{1}", LabWorkflowParameters.DeploymentDetails.PostDeploymentSnapshotName, BuildDetail.BuildNumber))] 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 | [BuildStatus] 184 | 185 | 186 | [Microsoft.TeamFoundation.Build.Client.BuildStatus.PartiallySucceeded] 187 | 188 | 189 | 190 | 191 | 192 | 193 | [BuildStatus] 194 | 195 | 196 | [Microsoft.TeamFoundation.Build.Client.BuildStatus.Failed] 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | -------------------------------------------------------------------------------- /BuildProcessTemplates/DefaultTemplate.11.1.xaml: -------------------------------------------------------------------------------- 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 | [New Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings()] 27 | [False] 28 | [New Microsoft.TeamFoundation.Build.Workflow.Activities.TestSpecList(New Microsoft.TeamFoundation.Build.Workflow.Activities.AgileTestPlatformSpec("**\*test*.dll"))] 29 | ["$(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)"] 30 | [False] 31 | [True] 32 | [True] 33 | [Microsoft.TeamFoundation.Build.Workflow.Activities.CleanWorkspaceOption.All] 34 | 35 | 36 | 37 | [Microsoft.TeamFoundation.Build.Workflow.Activities.CodeAnalysisOption.AsConfigured] 38 | [True] 39 | [Microsoft.TeamFoundation.Build.Workflow.Activities.ToolPlatform.Auto] 40 | [True] 41 | [New Microsoft.TeamFoundation.Build.Workflow.Activities.SourceAndSymbolServerSettings(True, Nothing)] 42 | [True] 43 | 44 | 45 | 46 | [New Microsoft.TeamFoundation.Build.Workflow.Activities.AgentSettings() With {.MaxWaitTime = New System.TimeSpan(4, 0, 0), .MaxExecutionTime = New System.TimeSpan(0, 0, 0), .TagComparison = Microsoft.TeamFoundation.Build.Workflow.Activities.TagComparison.MatchExactly }] 47 | [Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity.Normal] 48 | 49 | 50 | 51 | 52 | 53 | 54 | All 55 | 11.0 56 | Assembly references and imported namespaces serialized as XML namespaces 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 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | --------------------------------------------------------------------------------