├── LICENSE ├── Logo ├── Logo.psd ├── MWCC-Logo-1024.png ├── MWCC-Logo-256.png └── MWCC-Logo-512.png ├── PSModule ├── ModernWorkplaceClientCenter │ ├── Data │ │ ├── AzureEndpointCache.json │ │ ├── AzureEndpointExpectedResults.json │ │ └── UrlWildcardLookup.json │ ├── Functions │ │ ├── Get-BCStatusDetailed.ps1 │ │ ├── Get-DsRegStatus.ps1 │ │ ├── Get-MDMDeviceOwnership.ps1 │ │ ├── Get-MDMEnrollmentStatus.ps1 │ │ ├── Get-MDMMsiApp.ps1 │ │ ├── Get-MDMPSScriptStatus.ps1 │ │ ├── Get-SiteToZoneAssignment.ps1 │ │ ├── Invoke-AnalyzeAzureConnectivity.ps1 │ │ ├── Invoke-AnalyzeDeliveryOptimization.ps1 │ │ ├── Invoke-AnalyzeHybridJoinStatus.ps1 │ │ ├── Invoke-AnalyzeMDMEnrollmentStatus.ps1 │ │ ├── Invoke-IntuneCleanup.ps1 │ │ ├── Invoke-TestAutopilotNetworkEndpoint.ps1 │ │ └── Reset-MDMEnrollmentStatus.ps1 │ ├── Internal │ │ ├── Get-AzureEndpointExpectedResult.ps1 │ │ ├── Get-AzureO365UrlEndpoint.ps1 │ │ ├── Get-InstalledApplication.ps1 │ │ ├── Get-IsAdmin.ps1 │ │ ├── Get-NtpTime.ps1 │ │ ├── Get-UrlWildCardLookup.ps1 │ │ ├── Invoke-TranslateAppStatus.ps1 │ │ ├── Invoke-TranslateMDMEnrollmentType.ps1 │ │ └── New-AnalyzeResult.ps1 │ ├── ModernWorkplaceClientCenter.psd1 │ ├── ModernWorkplaceClientCenter.psm1 │ └── NestedModules │ │ ├── HttpConnectivityTester │ │ ├── HttpConnectivityTester.psd1 │ │ └── HttpConnectivityTester.psm1 │ │ └── TcpConnectivityTester │ │ ├── TcpConnectivityTester.psd1 │ │ └── TcpConnectivityTester.psm1 ├── build.ps1 └── cacheHttpResults.ps1 ├── README.md └── ReleaseNotes.md /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Logo/Logo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThomasKur/ModernWorkplaceClientCenter/05eb15ee9c2168ebf935a6521688268983506f00/Logo/Logo.psd -------------------------------------------------------------------------------- /Logo/MWCC-Logo-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThomasKur/ModernWorkplaceClientCenter/05eb15ee9c2168ebf935a6521688268983506f00/Logo/MWCC-Logo-1024.png -------------------------------------------------------------------------------- /Logo/MWCC-Logo-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThomasKur/ModernWorkplaceClientCenter/05eb15ee9c2168ebf935a6521688268983506f00/Logo/MWCC-Logo-256.png -------------------------------------------------------------------------------- /Logo/MWCC-Logo-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThomasKur/ModernWorkplaceClientCenter/05eb15ee9c2168ebf935a6521688268983506f00/Logo/MWCC-Logo-512.png -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Data/AzureEndpointCache.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThomasKur/ModernWorkplaceClientCenter/05eb15ee9c2168ebf935a6521688268983506f00/PSModule/ModernWorkplaceClientCenter/Data/AzureEndpointCache.json -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Data/AzureEndpointExpectedResults.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThomasKur/ModernWorkplaceClientCenter/05eb15ee9c2168ebf935a6521688268983506f00/PSModule/ModernWorkplaceClientCenter/Data/AzureEndpointExpectedResults.json -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Data/UrlWildcardLookup.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThomasKur/ModernWorkplaceClientCenter/05eb15ee9c2168ebf935a6521688268983506f00/PSModule/ModernWorkplaceClientCenter/Data/UrlWildcardLookup.json -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Get-BCStatusDetailed.ps1: -------------------------------------------------------------------------------- 1 | function Get-BCStatusDetailed(){ 2 | <# 3 | .Synopsis 4 | Returns Branch Cache usage statistsics of the last downloads per source host including peer usage statistics. 5 | 6 | .Description 7 | Returns Windows BranchCache usage statistsics of the last downloads per source host including peer usage statistics. With this information you are able to analyze if downloads are using the peers and save internet bandwidth. 8 | 9 | .Example 10 | # Displays a full report BranchCache downloads. 11 | Get-BCStatusDetailed 12 | #> 13 | $Events = Get-WinEvent -LogName "Microsoft-Windows-Bits-Client/Operational" | Where-Object { 60 -eq $_.Id } 14 | 15 | ForEach ($Event in $Events) { 16 | # Convert the event to XML 17 | $eventXML = [xml]$Event.ToXml() 18 | # Iterate through each one of the XML message properties 19 | For ($i=0; $i -lt $eventXML.Event.EventData.Data.Count; $i++) { 20 | if($eventXML.Event.EventData.Data[$i].name -eq "url"){ 21 | Add-Member -InputObject $Event -MemberType NoteProperty -Force -Name "UrlHost" -Value ([uri]($eventXML.Event.EventData.Data[$i].'#text')).DnsSafeHost 22 | } 23 | # Append these as object properties 24 | Add-Member -InputObject $Event -MemberType NoteProperty -Force -Name $eventXML.Event.EventData.Data[$i].name -Value $eventXML.Event.EventData.Data[$i].'#text' 25 | } 26 | } 27 | $BCStatsExtended = @() 28 | $BCStats = $Events | Group-Object -Property "UrlHost" 29 | foreach($BCStat in $BCStats){ 30 | $t = New-Object PSObject 31 | Add-Member -InputObject $t -MemberType NoteProperty -Force -Name "UrlHost" -Value $BCStat.Name 32 | Add-Member -InputObject $t -MemberType NoteProperty -Force -Name "Count" -Value $BCStat.Count 33 | Add-Member -InputObject $t -MemberType NoteProperty -Force -Name "MBTotal" -Value (($BCStat.Group | Measure-Object -Property bytesTotal -Sum).Sum/1MB) 34 | Add-Member -InputObject $t -MemberType NoteProperty -Force -Name "MBTransferedFromPeers" -Value (($BCStat.Group | Measure-Object -Property bytesTransferredFromPeer -Sum).Sum/1MB) 35 | Add-Member -InputObject $t -MemberType NoteProperty -Force -Name "peerProtocolFlagsOfFirstDownload" -Value (($BCStat.Group | Select-Object -First 1 -Property peerProtocolFlags).peerProtocolFlags) 36 | $BCStatsExtended += $t 37 | } 38 | $BCStatsExtended 39 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Get-DsRegStatus.ps1: -------------------------------------------------------------------------------- 1 | function Get-DsRegStatus { 2 | <# 3 | .Synopsis 4 | Returns the output of dsregcmd /status as a PSObject. 5 | 6 | .Description 7 | Returns the output of dsregcmd /status as a PSObject. All returned values are accessible by their property name. Now per section as a subobject. 8 | 9 | .Example 10 | # Displays a full output of dsregcmd / status. 11 | Get-DsRegStatus 12 | #> 13 | [cmdletbinding()] 14 | Param() 15 | $dsregcmd = & "$env:windir\system32\dsregcmd.exe" /status 2>&1 16 | $ResultObj = New-Object -TypeName PSObject 17 | 18 | # This was original pattern string but did not parse all properties 19 | ## $PatStr = ' *[A-z]+ : [A-z]+ *' 20 | 21 | # Updated RegEx pattern string 22 | $PatStr = ' *[^\n\r]+ : [^\n]+ *' 23 | 24 | # Parse through output using RegEx pattern, iterate through lines and build objects 25 | $null = $dsregcmd | Select-String -Pattern $PatStr | ForEach-Object { 26 | # Set noteproperty name 27 | $PropName = (([String]$_).Trim() -split " : ")[0] 28 | $PropName = $PropName.replace(' ', '') 29 | 30 | # Set noteproperty value 31 | $Val = (([String]$_).Trim() -split " : ")[1] 32 | # Replace YES/NO value with bool type 33 | $Val = $Val -Replace ('^YES$', [bool]$true) -Replace ('^NO$', [bool]$false) 34 | 35 | # Add property to PSObject of $ResultObj 36 | Add-Member -InputObject $ResultObj -MemberType NoteProperty -Name $PropName -Value $Val 37 | } 38 | $ResultObj 39 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Get-MDMDeviceOwnership.ps1: -------------------------------------------------------------------------------- 1 | function Get-MDMDeviceOwnership(){ 2 | <# 3 | .SYNOPSIS 4 | Returns information about the Ownership of the Device. 5 | .DESCRIPTION 6 | Returns information about the Ownership of the Device. 7 | - Corporate Owned 8 | - Personal Owned 9 | - Unknown: No information about Ownership found 10 | 11 | .EXAMPLE 12 | Get-MDMDeviceOwnership 13 | .NOTES 14 | 15 | #> 16 | if((Get-MDMEnrollmentStatus).EnrollmentState -eq 1){ 17 | $CorpOwned = Get-ItemPropertyValue -Path HKLM:\SOFTWARE\Microsoft\Enrollments\Ownership -Name CorpOwned -ErrorAction SilentlyContinue 18 | switch($CorpOwned){ 19 | 0{return "PersonalOwned"} 20 | 1{return "CorporateOwned"} 21 | $null{return "Unknown"} 22 | } 23 | } else { 24 | Write-Error "Device is not enrolled to MDM." 25 | } 26 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Get-MDMEnrollmentStatus.ps1: -------------------------------------------------------------------------------- 1 | function Get-MDMEnrollmentStatus { 2 | <# 3 | .Synopsis 4 | Get Windows 10 MDM Enrollment Status. 5 | 6 | .Description 7 | Get Windows 10 MDM Enrollment Status with Translated Error Codes. 8 | 9 | Returns $null if Device is not enrolled to an MDM. 10 | 11 | .Example 12 | # Get Windows 10 MDM Enrollment status 13 | Get-MDMEnrollmentStatus 14 | #> 15 | param() 16 | #Locate correct Enrollment Key 17 | $EnrollmentKey = Get-Item -Path HKLM:\SOFTWARE\Microsoft\Enrollments\* | Get-ItemProperty | Where-Object -FilterScript {$null -ne $_.UPN} 18 | if($EnrollmentKey){ 19 | Add-Member -InputObject $EnrollmentKey -MemberType NoteProperty -Name EnrollmentTypeText -Value (Invoke-TranslateMDMEnrollmentType -Id ($EnrollmentKey.EnrollmentType)) 20 | } else { 21 | Write-Error "Device is not enrolled to MDM." 22 | } 23 | return $EnrollmentKey 24 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Get-MDMMsiApp.ps1: -------------------------------------------------------------------------------- 1 | function Get-MDMMsiApp() { 2 | <# 3 | .SYNOPSIS 4 | Retrieves information about all MDM assigned applications, including their installation state. 5 | .DESCRIPTION 6 | Retrieves information about all MDM assigned applications by combining policy information combained with additional information from registry to provide a complete list. 7 | 8 | .EXAMPLE 9 | Get-MdmMsiApp 10 | .NOTES 11 | 12 | #> 13 | [OutputType([System.Object[]])] 14 | $AppStatus = @() 15 | if((Get-MDMEnrollmentStatus).EnrollmentState -eq 1){ 16 | $Users = Get-ChildItem HKLM:\SOFTWARE\Microsoft\EnterpriseDesktopAppManagement\ -ErrorAction SilentlyContinue 17 | if($Users){ 18 | $AddRemoveApps = Get-InstalledApplication 19 | foreach($user in $users){ 20 | if($user.PSChildName -eq "S-0-0-00-0000000000-0000000000-000000000-000") 21 | { 22 | $UserName = "LocalSystem" 23 | $Authority = "LocalSystem" 24 | } else { 25 | $objSID = New-Object System.Security.Principal.SecurityIdentifier($user.PSChildName) 26 | $objUser = $objSID.Translate( [System.Security.Principal.NTAccount]) 27 | $UserName = $objUser.Value.Split("\")[1] 28 | $Authority = $objUser.Value.Split("\")[0] 29 | } 30 | if(Test-Path "$($user.PSPath)\MSI"){ 31 | $Apps = Get-ChildItem "$($user.PSPath)\MSI" 32 | foreach($App in $Apps){ 33 | $App = ($App | Get-ItemProperty) 34 | $AppTemp = New-Object PSCustomObject 35 | $AddRemoveApp = $AddRemoveApps | Where-Object { $_.ProductCode -eq $App.PSChildName } 36 | if($AddRemoveApp){ 37 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "Publisher" -Value $AddRemoveApp.Publisher 38 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "DisplayVersion" -Value $AddRemoveApp.DisplayVersion 39 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "AppName" -Value $AddRemoveApp.DisplayName 40 | } else { 41 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "Publisher" -Value " " 42 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "DisplayVersion" -Value " " 43 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "AppName" -Value " " 44 | } 45 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "ProductCode" -Value $App.PSChildName 46 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "ProductVersion" -Value $App.ProductVersion 47 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "ActionType" -Value $App.ActionType 48 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "Status" -Value (Invoke-TranslateAppStatus -Id $App.Status) 49 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "LastError" -Value $App.LastError 50 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "DownloadLocation" -Value $App.DownloadLocation 51 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "DownloadInstall" -Value $App.DownloadInstall 52 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "DownloadUrlList" -Value $App.DownloadUrlList 53 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "CurrentDownloadUrl" -Value $App.CurrentDownloadUrl 54 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "EnforcementStartTime" -Value ([DateTime]::FromFileTime($App.EnforcementStartTime)) 55 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "EnforcementTimeout" -Value $App.EnforcementTimeout 56 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "EnforcementRetryIndex" -Value $App.EnforcementRetryIndex 57 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "EnforcementRetryCount" -Value $App.EnforcementRetryCount 58 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "EnforcementRetryInterval" -Value $App.EnforcementRetryInterval 59 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "LocURI" -Value $App.LocURI 60 | #Check if App is from Syntaro 61 | $SyntaroApp = $null 62 | $SyntaroApps = Get-ChildItem -Path HKLM:\SOFTWARE\Syntaro\ApplicationManagement\ -ErrorAction SilentlyContinue 63 | foreach($TempSyntaroApp in $SyntaroApps){ 64 | if((Get-ItemProperty -Path $TempSyntaroApp.PSPath).MsiCode -eq $App.PSChildName){ 65 | $SyntaroApp = (Get-ItemProperty -Path $TempSyntaroApp.PSPath) 66 | } 67 | } 68 | $App = Get-ItemProperty $App.PSPath 69 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "AssignedUserName" -Value $UserName 70 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "AssignedUserAuthority" -Value $Authority 71 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "AssignmentType" -Value $App.AssignmentType 72 | if($SyntaroApp){ 73 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "AppType" -Value "Syntaro" 74 | } else { 75 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "AppType" -Value "Native" 76 | } 77 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "SyntaroAction" -Value $SyntaroApp.Action 78 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "SyntaroProcessed" -Value $SyntaroApp.Processed 79 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "SyntaroNotFoundInRepo" -Value $SyntaroApp.NotFoundInRepo 80 | Add-Member -InputObject $AppTemp -MemberType NoteProperty -Name "CreationTime" -Value ([DateTime]::FromFileTime($App.CreationTime)) 81 | 82 | $AppStatus += $AppTemp 83 | 84 | } 85 | } 86 | } 87 | } else { 88 | Write-Warning "No application assignment found in registry." 89 | } 90 | } else { 91 | Write-Error "Device is not enrolled to MDM." 92 | } 93 | return $AppStatus 94 | } 95 | -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Get-MDMPSScriptStatus.ps1: -------------------------------------------------------------------------------- 1 | function Get-MDMPSScriptStatus(){ 2 | <# 3 | .SYNOPSIS 4 | Returns information about the execution of PowerShell Scripts deployed with Intune. 5 | .DESCRIPTION 6 | Returns information about the execution of PowerShell Scripts deployed with Intune. 7 | 8 | .EXAMPLE 9 | Get-MDMPSScriptStatus 10 | .NOTES 11 | 12 | #> 13 | $PSStatus = @() 14 | if((Get-MDMEnrollmentStatus).EnrollmentState -eq 1){ 15 | $Users = Get-ChildItem HKLM:\SOFTWARE\Microsoft\IntuneManagementExtension\Policies\ -ErrorAction SilentlyContinue 16 | foreach($user in $users){ 17 | $Scripts = Get-ChildItem "$($user.PSPath)" 18 | foreach($Script in $Scripts){ 19 | $Script = Get-ItemProperty $Script.PSPath 20 | $PSStatus += $App 21 | } 22 | } 23 | } else { 24 | Write-Error "Device is not enrolled to MDM." 25 | } 26 | return $PSStatus 27 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Get-SiteToZoneAssignment.ps1: -------------------------------------------------------------------------------- 1 | function Get-SiteToZoneAssignment{ 2 | <# 3 | .Synopsis 4 | Returns Internet Explorer Site to Zone assignments. 5 | 6 | .Description 7 | Returns a list of sites in the Trusted, Intranet or Restricted Sites of Internet explorer which are defined through Group Policy. 8 | 9 | Important: User defined are not returned. 10 | 11 | .Example 12 | # Displays all sites 13 | Get-SiteToZoneAssignment 14 | #> 15 | [CmdletBinding()] 16 | param() 17 | $_RegKeyList1 = @() 18 | $_RegKeyList2 = @() 19 | $_RegKeyInfo = @() 20 | Write-Verbose "Loading registry key 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMapKey'" 21 | $_RegKeyList1 = $(Get-Item 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMapKey' -ErrorAction SilentlyContinue) 22 | Write-Verbose "Loading registry key 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMapKey'" 23 | $_RegKeyList2 = $(Get-Item 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMapKey' -ErrorAction SilentlyContinue) 24 | 25 | 26 | Write-Information "Found $($_RegKeyList1.Count) Site to zone assignments for Current User." 27 | Foreach($_RegValue in $_RegKeyList1.Property){ 28 | $Value = ($_RegKeyList1 | Get-ItemProperty).$($_RegValue) 29 | Switch($Value){ 30 | 0 {$_ZoneType = 'My Computer'} 31 | 1 {$_ZoneType = 'Local Intranet Zone'} 32 | 2 {$_ZoneType = 'Trusted sites Zone'} 33 | 3 {$_ZoneType = 'Internet Zone'} 34 | 4 {$_ZoneType = 'Restricted Sites Zonet'} 35 | Default { break } 36 | } 37 | $newEntry = New-Object -TypeName PSObject 38 | Add-Member -InputObject $newEntry -MemberType NoteProperty -Name "Zone" -Value $_ZoneType 39 | Add-Member -InputObject $newEntry -MemberType NoteProperty -Name "Url" -Value $_RegValue 40 | Write-Verbose "Detected '$($newEntry.Url)' --> '$($newEntry.Zone)'" 41 | $_RegKeyInfo += $newEntry 42 | 43 | } 44 | Write-Information "Found $($_RegKeyList2.Count) Site to zone assignments for Current Machine." 45 | Foreach($_RegValue in $_RegKeyList2.Property){ 46 | $Value = ($_RegKeyList2 | Get-ItemProperty).$($_RegValue) 47 | Switch($Value){ 48 | 0 {$_ZoneType = 'My Computer'} 49 | 1 {$_ZoneType = 'Local Intranet Zone'} 50 | 2 {$_ZoneType = 'Trusted sites Zone'} 51 | 3 {$_ZoneType = 'Internet Zone'} 52 | 4 {$_ZoneType = 'Restricted Sites Zonet'} 53 | Default { break } 54 | } 55 | $newEntry = New-Object -TypeName PSObject 56 | Add-Member -InputObject $newEntry -MemberType NoteProperty -Name "Zone" -Value $_ZoneType 57 | Add-Member -InputObject $newEntry -MemberType NoteProperty -Name "Url" -Value $_RegValue 58 | Write-Verbose "Detected '$($newEntry.Url)' --> '$($newEntry.Zone)'" 59 | $_RegKeyInfo += $newEntry 60 | 61 | } 62 | return $_RegKeyInfo 63 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Invoke-AnalyzeAzureConnectivity.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-AnalyzeAzureConnectivity { 2 | <# 3 | .Synopsis 4 | Analyzes the connectifity to O365 and Azure Endpoints. 5 | 6 | .Description 7 | Analyzes the connectifity to O365 and Azure Endpoints according to https://docs.microsoft.com/en-us/office365/enterprise/urls-and-ip-address-ranges. 8 | 9 | Returns array of Messages with four properties: 10 | 11 | - Testname: Name of the Tets 12 | - Type: Information, Warning or Error 13 | - Issue: Description of the issue 14 | - Possible Cause: Tips on how to solve the issue. 15 | 16 | .Example 17 | # Displays a deep analyisis of the currently found issues in the system. 18 | Invoke-AnalyzeAzureConnectivity 19 | 20 | #> 21 | [alias("Invoke-AnalyzeO365Connectivity")] 22 | [CmdletBinding()] 23 | param( 24 | [ValidateSet("Common","Exchange","Skype","SharePoint","All")] 25 | [String] 26 | $UrlSet = "Common", 27 | [Switch] 28 | $OnlyRequired 29 | ) 30 | 31 | Write-Verbose "Conenctivity Tests to Azure Endpoints in $UrlSet category, which are Required=$OnlyRequired." 32 | $data = New-Object System.Collections.Generic.List[PSCustomObject] 33 | $possibleErrors = @() 34 | $results = New-Object System.Collections.Generic.List[pscustomobject] 35 | Write-Progress -Activity "Connectivity Tests" -status "Load TestUrls" -percentComplete 0 36 | 37 | $EndpointsObjs = Get-AzureO365UrlEndpoint -Path ((Get-Item $PSScriptRoot).Parent.FullName) 38 | $EndpointsObjs = $EndpointsObjs | Where-Object { ($_.serviceArea -eq $UrlSet -or $UrlSet -eq "All") -and ($OnlyRequired -eq $false -or $_.required -eq $true)} 39 | Write-Progress -Activity "Connectivity Tests" -status "Load TestUrls finisehed" -percentComplete 100 40 | Write-Verbose "Found $($EndpointsObjs.length) endpoints to check" 41 | $j = 0 42 | foreach($EndpointsObj in $EndpointsObjs){ 43 | Write-Progress -Activity "Connectivity Tests" -status "Building urls for $($EndpointsObj.serviceArea) with id $($EndpointsObj.id)" -percentComplete ($j / $EndpointsObjs.length*100) 44 | if($null -eq $EndpointsObj.tcpPorts){ 45 | Add-Member -InputObject $EndpointsObj -MemberType NoteProperty -Name tcpPorts -Value "443" 46 | } 47 | foreach($Port in $EndpointsObj.tcpPorts.Split(',')){ 48 | switch ($Port) { 49 | 80 {$Protocol = "http://"; $UsePort = "";$TestType="HTTP"; break} 50 | 443 {$Protocol = "https://"; $UsePort = "";$TestType="HTTP"; break} 51 | default {$Protocol = ""; $UsePort = $Port;$TestType="TCP"; break} 52 | } 53 | if($EndpointsObj.PSObject.Properties.Name -match "notes"){ 54 | $Notes = " - " + $EndpointsObj.notes 55 | } else { 56 | $Notes = "" 57 | } 58 | foreach($url in $EndpointsObj.urls){ 59 | if($TestType -eq "HTTP"){ 60 | $ExpectedResult = Get-AzureEndpointExpectedResult -TestType $TestType -Url ($Protocol + $url) -Path ((Get-Item $PSScriptRoot).Parent.FullName) 61 | } else { 62 | $ExpectedResult = Get-AzureEndpointExpectedResult -TestType $TestType -Url ($url + ":" + $UsePort) -Path ((Get-Item $PSScriptRoot).Parent.FullName) 63 | } 64 | if($url -notmatch "\*"){ 65 | $data.Add([PSCustomObject]@{ TestType = $TestType; TestUrl = $url; UsePort = $UsePort; Protocol = $Protocol; UrlPattern = $url; ExpectedStatusCode = $ExpectedResult.ActualStatusCode; Description = "$($EndpointsObj.serviceAreaDisplayName)$Notes"; PerformBluecoatLookup=$false; IgnoreCertificateValidationErrors=$ExpectedResult.HasError; Blocked=$ExpectedResult.Blocked; Verbose=$false }) 66 | } else { 67 | $staticUrls = Get-UrlWildCardLookup -Url $url -Path ((Get-Item $PSScriptRoot).Parent.FullName) 68 | if($staticUrls){ 69 | foreach($staticUrl in $staticUrls){ 70 | $data.Add([PSCustomObject]@{ TestType = $TestType; TestUrl = $staticUrl; UsePort = $UsePort; Protocol = $Protocol; UrlPattern = $url; ExpectedStatusCode = $ExpectedResult.ActualStatusCode; Description = "$($EndpointsObj.serviceAreaDisplayName)$Notes"; PerformBluecoatLookup=$false; IgnoreCertificateValidationErrors=$ExpectedResult.HasError; Blocked=$ExpectedResult.Blocked; Verbose=$false }) 71 | } 72 | } else { 73 | 74 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Warning" -Issue "Could not check connectivity to $url and Port $Port because no static url for this wildcard url was found." -PossibleCause $Cause 75 | } 76 | } 77 | } 78 | <#if($EndpointsObj.PSObject.Properties.Name -match "ips"){ 79 | foreach($ip in $EndpointsObj.ips){ 80 | $firstip = $ip.Split("/")[0] 81 | $data.Add(@{ TestUrl = ($Protocol + $firstip + $UsePort); UrlPattern = ($Protocol + $firstip + $UsePort); ExpectedStatusCode = 403; Description = "$($EndpointsObj.serviceAreaDisplayName) - $Notes - Need communication $Protocol to $ip"; PerformBluecoatLookup=$false; Verbose=$false }) 82 | } 83 | }#> 84 | } 85 | } 86 | 87 | $possibleErrors = $possibleErrors | Group-Object -Property @("Type", "Issue") | ForEach-Object{ $_.Group | Select-Object * -First 1} 88 | $i = 1 89 | $dataObjs = $data | Group-Object -Property @("TestUrl","TestType","UsePort") | ForEach-Object{ $_.Group | Select-Object * -First 1} 90 | ForEach($dataObj in $dataObjs) { 91 | Write-Progress -Activity "Connectivity Tests" -status "Processing $($d.TestUrl)" -percentComplete ($i / $dataObjs.count*100) 92 | if($dataObj.TestType -eq "HTTP"){ 93 | $connectivity = Get-HttpConnectivity -TestUrl ($dataObj.Protocol + $dataObj.TestUrl) -Method "GET" -UrlPattern ($dataObj.Protocol + $dataObj.UrlPattern) -ExpectedStatusCode $dataObj.ExpectedStatusCode -Description $dataObj.Description -PerformBluecoatLookup $dataObj.PerformBluecoatLookup -IgnoreCertificateValidationErrors:$dataObj.IgnoreCertificateValidationErrors 94 | } else { 95 | $connectivity = Get-TcpConnectivity -TestHostname $dataObj.TestUrl -TestPort $dataObj.UsePort -HostnamePattern ($dataObj.UrlPattern + ":" + $dataObj.UsePort) -ExpectedStatusCode $dataObj.ExpectedStatusCode -Description $dataObj.Description 96 | } 97 | $results.Add($connectivity) 98 | if ($connectivity.Blocked -eq $true -and $dataObj.Blocked -eq $false) { 99 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Error" -Issue "Connection blocked `n $($connectivity)" -PossibleCause "Firewall is blocking connection to '$($connectivity.UnblockUrl)'." 100 | } elseif ($connectivity.ExpectedStatusCode -notcontains $connectivity.ActualStatusCode) { 101 | if($connectivity.ActualStatusCode -eq 407){ 102 | $Cause = "Keep in mind that the proxy has to be set in WinHTTP.`nWindows 1709 and newer: Set the proxy by using netsh or WPAD. --> https://docs.microsoft.com/en-us/windows/desktop/WinHttp/winhttp-autoproxy-support `nWindows 1709 and older: Set the proxy by using 'netsh winhttp set proxy ?' --> https://blogs.technet.microsoft.com/netgeeks/2018/06/19/winhttp-proxy-settings-deployed-by-gpo/ " 103 | } else { 104 | $Cause = "Interfering Proxy server can change HTTP status codes." 105 | } 106 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Error" -Issue "Returned Status code '$($connectivity.ActualStatusCode)' is not expected '$($connectivity.ExpectedStatusCode)'`n $($connectivity)" -PossibleCause $Cause 107 | } 108 | if ($connectivity.Resolved -eq $false) { 109 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Error" -Issue "DNS name not resolved `n $($connectivity)" -PossibleCause "DNS server not correctly configured." 110 | } 111 | 112 | if ($null -ne $connectivity.ServerCertificate -and $connectivity.ServerCertificate.HasError -and -not $dataObj.IgnoreCertificateValidationErrors) { 113 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Error" -Issue "Certificate Error when connecting to $($connectivity.TestUrl)`n $(($connectivity.ServerCertificate))" -PossibleCause "Interfering Proxy server can change Certificate or not the Root Certificate is not trusted." 114 | } 115 | $i += 1 116 | } 117 | Write-Progress -Completed -Activity "Connectivity Tests" 118 | 119 | # No errors detected, return success message 120 | if ($possibleErrors.Count -eq 0) { 121 | $possibleErrors += New-AnalyzeResult -TestName "All" -Type Information -Issue "All tests went through successfully." -PossibleCause "" 122 | } 123 | 124 | return $possibleErrors 125 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Invoke-AnalyzeDeliveryOptimization.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-AnalyzeDeliveryOptimization { 2 | <# 3 | .Synopsis 4 | Analyzes current device regarding the possibility to use Delivery Optimization. 5 | 6 | .Description 7 | Delivery Optimization is the built-in feature to optimize data traffic and a lot of Microsoft products and services are using it. Therefore it's crucial, that you are aware of the status in your environment. 8 | 9 | Returns array of Messages with four properties: 10 | 11 | - Testname: Name of the Tets 12 | - Type: Information, Warning or Error 13 | - Issue: Description of the issue 14 | - Possible Cause: Tips on how to solve the issue. 15 | 16 | .Example 17 | # Displays a deep analyisis of the currently found issues in the system. 18 | Invoke-AnalyzeDeliveryOptimization 19 | 20 | #> 21 | [alias("Invoke-AnalyzeDO")] 22 | param( 23 | ) 24 | $possibleErrors = @() 25 | Write-Verbose "Checking Service Status" 26 | if((get-service "DoSvc").Status -ne "Running"){ 27 | if((get-service "DoSvc").StartType -eq "Automatic"){ 28 | $possibleErrors += New-AnalyzeResult -TestName "Service" -Type Error -Issue "The Delivery Optimization Service (DoSvc) is not running on the system." -PossibleCause "Try to to start it again `nStart-Service -Name DoSvc" 29 | } else { 30 | $possibleErrors += New-AnalyzeResult -TestName "Service" -Type Error -Issue "The Delivery Optimization Service (DoSvc) is not running on the system and the start type is not 'Automatic', therefore an administrator has changed this behavior." -PossibleCause "Chnage the startup type to automatic and start the service. `nSet-Service -Name DoSvc -StartupType Automatic`nStart-Service -Name DoSvc" 31 | } 32 | } 33 | 34 | Write-Verbose "Checking local Firewall" 35 | $FwProfiles = Get-NetFirewallProfile 36 | if($FwProfiles.Count -ne ($FwProfiles | Where-Object{$_.Enabled -eq $true}).Count){ 37 | $possibleErrors += New-AnalyzeResult -TestName "Firewall" -Type Warning -Issue "Not all Windows Firewall profiles are enabled. Therefore, the other FIrewall related warnings can be incorrect, because the profile in the network you would like to use DO is disabled and therefore the firewall rules are not needed." -PossibleCause "Check if a Firewall Profile is used in your network or not. If not, then you can ignore the other Firewall related issues." 38 | } 39 | $FwRules = Get-NetFirewallRule @("DeliveryOptimization-UDP-In","DeliveryOptimization-TCP-In") 40 | if($FwRules.Count -ne 2){ 41 | $possibleErrors += New-AnalyzeResult -TestName "Firewall" -Type Warning -Issue "Not all default Firewall Rules(DeliveryOptimization-UDP-In, DeliveryOptimization-TCP-In) regarding Delivery Optimization are found on your system." -PossibleCause "Perhaps you or another administrator has created custom rules and enabled them. These should allow incoming TCP/UDP 7680 connections on the peers. `n You can verify the connection to a peer by using the following command:`n Test-NetConnection -ComputerName %ipofpeer% -Port 7680" 42 | } else { 43 | if($FwRules[0].Profile -ne "Any"){ 44 | $possibleErrors += New-AnalyzeResult -TestName "Firewall" -Type Warning -Issue "The rule $($FwRules[0].Name) is not aplied to all profiles(Public, Private, Domain)." -PossibleCause "Check if the you are using DO in a network which is not assigned to a profile where the rule is active($($FwRules[0].Profile))." 45 | } 46 | if($FwRules[1].Profile -ne "Any"){ 47 | $possibleErrors += New-AnalyzeResult -TestName "Firewall" -Type Warning -Issue "The rule $($FwRules[1].Name) is not aplied to all profiles(Public, Private, Domain)." -PossibleCause "Check if the you are using DO in a network which is not assigned to a profile where the rule is active($($FwRules[1].Profile))." 48 | } 49 | if($FwRules[0].Action -ne "Allow"){ 50 | $possibleErrors += New-AnalyzeResult -TestName "Firewall" -Type Warning -Issue "The rule $($FwRules[0].Name) does not Allow the Traffic." -PossibleCause "Change the Action to Allow in the rule." 51 | } 52 | if($FwRules[1].Action -ne "Allow"){ 53 | $possibleErrors += New-AnalyzeResult -TestName "Firewall" -Type Warning -Issue "The rule $($FwRules[1].Name) does not Allow the Traffic." -PossibleCause "Change the Action to Allow in the rule." 54 | } 55 | if($FwRules[0].Direction -ne "Inbound"){ 56 | $possibleErrors += New-AnalyzeResult -TestName "Firewall" -Type Warning -Issue "The rule $($FwRules[0].Name) does not target inbound traffic." -PossibleCause "Change the Direction to inbound in the rule." 57 | } 58 | if($FwRules[1].Direction -ne "Inbound"){ 59 | $possibleErrors += New-AnalyzeResult -TestName "Firewall" -Type Warning -Issue "The rule $($FwRules[1].Name) does not target inbound traffic." -PossibleCause "Change the Direction to inbound in the rule." 60 | } 61 | if($FwRules[0].Enabled -ne $true){ 62 | $possibleErrors += New-AnalyzeResult -TestName "Firewall" -Type Warning -Issue "The rule $($FwRules[0].Name) is not enabled." -PossibleCause "Enable the rule." 63 | } 64 | if($FwRules[1].Enabled -ne $true){ 65 | $possibleErrors += New-AnalyzeResult -TestName "Firewall" -Type Warning -Issue "The rule $($FwRules[1].Name) is not enabled." -PossibleCause "Enable the rule." 66 | } 67 | } 68 | 69 | Write-Verbose "Conenctivity Tests to Delivery Optimization Service" 70 | $data = New-Object System.Collections.Generic.List[System.Collections.Hashtable] 71 | 72 | # https://docs.microsoft.com/en-us/windows/privacy/manage-windows-endpoints#windows-update 73 | $data.Add(@{ TestUrl = 'https://geo-prod.do.dsp.mp.microsoft.com'; UrlPattern = 'https://*.do.dsp.mp.microsoft.com'; ExpectedStatusCode = 403; Description = 'Updates for applications and the OS on Windows 10 1709 and later. Windows Update Delivery Optimization metadata, resiliency, and anti-corruption.'; PerformBluecoatLookup=$false; Verbose=$false }) # many different *-prod.do.dsp.mp.microsoft.com, but geo-prod.do.dsp.mp.microsoft.com is the most common one 74 | 75 | $results = New-Object System.Collections.Generic.List[pscustomobject] 76 | 77 | $data | ForEach-Object { 78 | $connectivity = Get-HttpConnectivity @_ 79 | $results.Add($connectivity) 80 | if ($connectivity.Blocked -eq $true) { 81 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Error" -Issue "Connection blocked `n $($connectivity)" -PossibleCause "Firewall is blocking connection to '$($connectivity.UnblockUrl)'. Delivery Optimization contacts a cloud service for a list of peers. This service uses HTTPS to *.do.dsp.mp.microsoft.com (communication to this service has to be allowed outbound to the Internet even if only local sharing is enabled)." 82 | } 83 | if ($connectivity.Resolved -eq $false) { 84 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Error" -Issue "DNS name not resolved `n $($connectivity)" -PossibleCause "DNS server not correctly configured." 85 | } 86 | if ($connectivity.ExpectedStatusCode -notcontains $connectivity.ActualStatusCode) { 87 | if($connectivity.ActualStatusCode -eq 407){ 88 | $Cause = "Keep in mind that the proxy has to be set in WinHTTP.`nWindows 1709 and newer: Set the proxy by using netsh or WPAD. --> https://docs.microsoft.com/en-us/windows/desktop/WinHttp/winhttp-autoproxy-support `nWindows 1709 and older: Set the proxy by using 'netsh winhttp set proxy ?' --> https://blogs.technet.microsoft.com/netgeeks/2018/06/19/winhttp-proxy-settings-deployed-by-gpo/ " 89 | } else { 90 | $Cause = "Interfering Proxy server can change HTTP status codes." 91 | } 92 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Error" -Issue "Returned HTTP Status code '$($connectivity.ActualStatusCode)' is not expected '$($connectivity.ExpectedStatusCode)'`n $($connectivity)" -PossibleCause $Cause 93 | } 94 | if ($null -ne $connectivity.ServerCertificate -and $connectivity.ServerCertificate.HasError) { 95 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Error" -Issue "Certificate Error when connecting to $($connectivity.TestUrl)`n $(($connectivity.ServerCertificate))" -PossibleCause "Interfering Proxy server can change Certificate or not the Root Certificate is not trusted." 96 | } 97 | } 98 | 99 | Write-Verbose "Checking Configuration (Policy)" 100 | $PolicyDODownloadMode = get-ItemPropertyValue HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization -Name DODownloadMode -ErrorAction SilentlyContinue 101 | if($null -ne $PolicyDODownloadMode -and @(1,2,3) -contains $PolicyDODownloadMode){ 102 | $possibleErrors += New-AnalyzeResult -TestName "Configuration" -Type "Error" -Issue "A policy is disabling Delivery Optimization and enforce mode $PolicyDODownloadMode. 0=HTTP only, no peering. 1=HTTP blended with peering behind the same NAT. 2=HTTP blended with peering across a private group. Peering occurs on devices in the same Active Directory Site (if exist) or the same domain by default. When this option is selected, peering will cross NATs. To create a custom group use Group ID in combination with Mode 2. 3=HTTP blended with Internet Peering. 99=Simple download mode with no peering. Delivery Optimization downloads using HTTP only and does not attempt to contact the Delivery Optimization cloud services. 100=Bypass mode. Do not use Delivery Optimization and use BITS instead." -PossibleCause "Change the assigned GPO or the local GPO and switch to mode 1,2 or 3. You can find the setting in the following path in GPO: `nComputer Configuration > Policies > Administrative Templates > Windows Components > Delivery Optimization > Download Mode" 103 | } 104 | $ConfigDODownloadMode = get-ItemPropertyValue HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config -Name DODownloadMode -ErrorAction SilentlyContinue 105 | if($null -ne $ConfigDODownloadMode -and @(1,2,3) -contains $ConfigDODownloadMode){ 106 | $possibleErrors += New-AnalyzeResult -TestName "Configuration" -Type "Error" -Issue "The Actual used configuration is disabling Delivery Optimization and uses mode $ConfigDODownloadMode. 0=HTTP only, no peering. 1=HTTP blended with peering behind the same NAT. 2=HTTP blended with peering across a private group. Peering occurs on devices in the same Active Directory Site (if exist) or the same domain by default. When this option is selected, peering will cross NATs. To create a custom group use Group ID in combination with Mode 2. 3=HTTP blended with Internet Peering. 99=Simple download mode with no peering. Delivery Optimization downloads using HTTP only and does not attempt to contact the Delivery Optimization cloud services. 100=Bypass mode. Do not use Delivery Optimization and use BITS instead." -PossibleCause "If you don't have any other warning regarding configuration from GPO or SettingsAppChange, then change the registry value to mode 1,2 or 3.`nHKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config `nValueName: DODownloadMode" 107 | } 108 | $UserSettingsDODownloadMode = get-ItemPropertyValue HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config -Name DODownloadMode -ErrorAction SilentlyContinue 109 | if($null -ne $UserSettingsDODownloadMode -and @(1,2,3) -contains $UserSettingsDODownloadMode){ 110 | $possibleErrors += New-AnalyzeResult -TestName "Configuration" -Type "Error" -Issue "The user has disabled Delivery Optimization through the settings app and set mode $UserSettingsDODownloadMode. 0=HTTP only, no peering. 1=HTTP blended with peering behind the same NAT. 2=HTTP blended with peering across a private group. Peering occurs on devices in the same Active Directory Site (if exist) or the same domain by default. When this option is selected, peering will cross NATs. To create a custom group use Group ID in combination with Mode 2. 3=HTTP blended with Internet Peering. 99=Simple download mode with no peering. Delivery Optimization downloads using HTTP only and does not attempt to contact the Delivery Optimization cloud services. 100=Bypass mode. Do not use Delivery Optimization and use BITS instead." -PossibleCause "Open the Settings App and search for Delivery Optmization and enable it." 111 | } 112 | # No errors detected, return success message 113 | if ($possibleErrors.Count -eq 0) { 114 | $possibleErrors += New-AnalyzeResult -TestName "All" -Type Information -Issue "All tests went through successfully." -PossibleCause "" 115 | } 116 | 117 | return $possibleErrors 118 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Invoke-AnalyzeHybridJoinStatus.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-AnalyzeHybridJoinStatus { 2 | <# 3 | .Synopsis 4 | Analyzes current status of the device regarding Azure AD Hybrid Join. 5 | 6 | .Description 7 | Analyzes current status of the device regarding Azure AD Hybrid Join. It checks also AD Service Connection Points and IE Site Assignments and GPO Settings. 8 | 9 | Returns array of Messages with four properties: 10 | 11 | - Testname: Name of the Tets 12 | - Type: Information, Warning or Error 13 | - Issue: Description of the issue 14 | - Possible Cause: Tips on how to solve the issue. 15 | 16 | .Parameter IncludeEventLog 17 | By specifying this command also the most relevant Windows Event Log entries from the last 10 Minutes related to Azure AD and Hybrid Join are included in the Output of this CmdLet. 18 | 19 | .Example 20 | # Displays a deep analyisis of the currently found issues in the system. 21 | Invoke-AnalyzeHybridJoinStatus 22 | 23 | #> 24 | param( 25 | [switch]$IncludeEventLog 26 | ) 27 | $dsreg = Get-DsRegStatus 28 | $possibleErrors = @() 29 | if ($dsreg.AzureAdJoined -eq "NO") { 30 | $possibleErrors += New-AnalyzeResult -TestName "AzureAdJoined" -Type Error -Issue "The join to Azure AD has not completed yet." -PossibleCause "Authentication of the computer for a join failed. 31 | There is an HTTP proxy in the organization that cannot be discovered by the computer 32 | The computer cannot reach Azure AD to authenticate or Azure DRS for registration 33 | The computer may not be on the organization's internal network or on VPN with direct line of sight to an on-premises AD domain controller. 34 | If the computer has a TPM, it can be in a bad state. 35 | There might be a misconfiguration in the services noted in the document earlier that you will need to verify again. Common examples are: 36 | - Your federation server does not have WS-Trust endpoints enabled 37 | - Your federation server does not allow inbound authentication from computers in your network using Integrated Windows Authentication. 38 | - There is no Service Connection Point object that points to your verified domain name in Azure AD in the AD forest where the computer belongs to." 39 | } 40 | 41 | if ($dsreg.DomainJoined -eq "NO") { 42 | $possibleErrors += New-AnalyzeResult -TestName "DomainJoined" -Type Error -Issue "The device is not joined to an on-premises Active Directory. Therefore, the device cannot perform a hybrid Azure AD join." -PossibleCause "Join the device to a domain, otherwise no Hybrid Join will be possible." 43 | } 44 | else { 45 | # Check Service Connection Point 46 | $Forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() 47 | $getdomaindn = $Forest.RootDomain.Name.Split('.') -join ",DC=" 48 | $scp = New-Object System.DirectoryServices.DirectoryEntry 49 | $scp.Path = "LDAP://CN=62a0ff2e-97b9-4513-943f-0d221bd30080,CN=Device Registration Configuration,CN=Services,CN=Configuration,DC=$getdomaindn"; 50 | if ([String]::IsNullOrWhiteSpace($scp.Keywords)) { 51 | $possibleErrors += New-AnalyzeResult -TestName "ADServiceConnectionPoint" -Type Error -Issue "No Service Connection Point defined in Active Directory." -PossibleCause "Join the device to a domain, otherwise no Hybrid Join will be possible." 52 | } 53 | else { 54 | $possibleErrors += New-AnalyzeResult -TestName "ADServiceConnectionPoint" -Type Warning -Issue "Current Value: $($scp.Keywords) `n Validate if the AzureAD GUID and tenant name is correct." -PossibleCause "Sometimes there are incorrect vslues left from a PoC or Testenvironment which can result in an incorrect entriy." 55 | } 56 | 57 | if ($dsreg.WorkplaceJoined -eq "YES") { 58 | if ($dsreg.DomainJoined -eq "YES") { 59 | $possibleErrors += New-AnalyzeResult -TestName "WorkplaceJoined" -Type Error -Issue "A work or school account was added before the completion of a hybrid Azure AD join." -PossibleCause "If the value is YES, a work or school account was added prior to the completion of the hybrid Azure AD join. In this case, the account is ignored when using the Anniversary Update version of Windows 10 (1607). This value should be NO for a domain-joined computer that is also hybrid Azure AD joined." 60 | } 61 | } 62 | 63 | $IESites = Get-SiteToZoneAssignment | Where-Object { ($_.Url -eq "https://autologon.microsoftazuread-sso.com" -or $_.Url -eq "autologon.microsoftazuread-sso.com") -and $_.Zone -eq "Local Intranet Zone" } 64 | if ($null -eq $IESites) { 65 | #Check if it is also not set manually: 66 | $IESitesManual = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\microsoftazuread-sso.com\autologon" -Name https -ErrorAction SilentlyContinue 67 | if($IESitesManual -ne 1){ 68 | $possibleErrors += New-AnalyzeResult -TestName "IE Site Assignment" -Type Warning -Issue "We could not detect https://autologon.microsoftazuread-sso.com in the Local Intranet Zone of Internet Explorer." -PossibleCause "One possibility is, that you have configured it manually on this test client in Internet Explorer. This check only validates, if it is assigned through a group policy. 69 | The second option is, that you configured a toplevel site in the intranet site and not especially the above mentioned URL including the protocol." 70 | } 71 | } 72 | 73 | $IESites = Get-SiteToZoneAssignment | Where-Object { ($_.Url -eq "https://device.login.microsoftonline.com" -or $_.Url -eq "device.login.microsoftonline.com") -and $_.Zone -eq "Local Intranet Zone" } 74 | if ($null -eq $IESites) { 75 | #Check if it is also not set manually: 76 | $IESitesManual = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\microsoftonline.com\device.login" -Name https -ErrorAction SilentlyContinue 77 | if($IESitesManual -ne 1){ 78 | $possibleErrors += New-AnalyzeResult -TestName "IE Site Assignment" -Type Warning -Issue "We could not detect https://device.login.microsoftonline.com in the Local Intranet Zone of Internet Explorer. To avoid certificate prompts when users in register devices authenticate to Azure AD you can push a policy to your domain-joined devices to add the following URL to the Local Intranet zone in Internet Explorer." -PossibleCause "One possibility is, that you have configured it manually on this test client in Internet Explorer. This check only validates, if it is assigned through a group policy. 79 | The second option is, that you configured a toplevel site in the intranet site and not especially the above mentioned URL including the protocol." 80 | } 81 | } 82 | # GPO Checks 83 | try { 84 | $IEStatusBarUpdates = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1" -Name 2103 -ErrorAction SilentlyContinue 85 | } 86 | catch { 87 | $IEStatusBarUpdates = $null 88 | } 89 | if ($IEStatusBarUpdates -eq 3) { 90 | $possibleErrors += New-AnalyzeResult -TestName "IE Update Status Bar" -Type Error -Issue "The following setting should be enabled in the user's intranet zone, if you plan to use SSO: 'Allow status bar updates via script.'. This is also the default value, which means you have a policy which disables this explicity." -PossibleCause "Reconfigure the policy" 91 | } 92 | try { 93 | $AutoDeviceReg = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WorkplaceJoin" -Name autoWorkplaceJoin -ErrorAction SilentlyContinue 94 | } 95 | catch { 96 | $AutoDeviceReg = $null 97 | } 98 | if ($AutoDeviceReg -ne 1) { 99 | $possibleErrors += New-AnalyzeResult -TestName "Auto Workplace Join GPO" -Type Error -Issue "The following setting should be enabled to trigger the automatic Azure AD Hybrid Join." -PossibleCause "Reconfigure the policy: Computer Configuration > Policies > Administrative Templates > Windows Components > Device Registration > Register domain-joined computers as devices" 100 | } 101 | } 102 | 103 | 104 | 105 | if ($dsreg.WamDefaultSet -eq "NO") { 106 | $possibleErrors += New-AnalyzeResult -TestName "WamDefaultSet" -Type Error -Issue "These fields indicate whether the user has successfully authenticated to Azure AD when signing in to the device." -PossibleCause "If the values are NO, it could be due: 107 | Bad storage key (STK) in TPM associated with the device upon registration (check the KeySignTest while running elevated). 108 | Alternate Login ID 109 | HTTP Proxy not found" 110 | } 111 | 112 | if ($dsreg.AzureAdPrt -eq "NO") { 113 | $possibleErrors += New-AnalyzeResult -TestName "AzureAdPrt" -Type Error -Issue "These fields indicate whether the user has successfully authenticated to Azure AD when signing in to the device." -PossibleCause "If the values are NO, it could be due: 114 | Bad storage key (STK) in TPM associated with the device upon registration (check the KeySignTest while running elevated). 115 | Alternate Login ID 116 | HTTP Proxy not found" 117 | } 118 | 119 | # Analyze Eventlogs 120 | if ($IncludeEventLog) { 121 | $AADEvents = Get-WinEvent -LogName "Microsoft-Windows-AAD/Operational" | Where-Object { ($_.LevelDisplayName -eq "Error" -or $_.LevelDisplayName -eq "Warning") -and $_.TimeCreated -gt [DateTime]::Now.AddMinutes(-10) } 122 | foreach ($AADEvent in ($AADEvents | Group-Object -Property Id)) { 123 | $possibleErrors += New-AnalyzeResult -TestName "EventLog-AAD" -Type ($AADEvent.Group[0].LevelDisplayName) -Issue "EventId: $($AADEvent.Name)`n$($AADEvent.Group[0].Message)" -PossibleCause "" 124 | } 125 | $WPJoinEvents = Get-WinEvent -LogName "Microsoft-Windows-Workplace Join/Admin" | Where-Object { ($_.LevelDisplayName -eq "Error" -or $_.LevelDisplayName -eq "Warning") -and $_.TimeCreated -gt [DateTime]::Now.AddMinutes(-10) } 126 | foreach ($WPJoinEvent in ($WPJoinEvents | Group-Object -Property Id)) { 127 | $possibleErrors += New-AnalyzeResult -TestName "EventLog-WorkplaceJoin" -Type ($WPJoinEvent.Group[0].LevelDisplayName) -Issue "EventId: $($WPJoinEvent.Name)`n$($WPJoinEvent.Group[0].Message)" -PossibleCause "" 128 | } 129 | $UsrDevRegEvents = Get-WinEvent -LogName "Microsoft-Windows-User Device Registration/Admin" | Where-Object { ($_.LevelDisplayName -eq "Error" -or $_.LevelDisplayName -eq "Warning") -and $_.TimeCreated -gt [DateTime]::Now.AddMinutes(-10) } 130 | foreach ($UsrDevRegEvent in ($UsrDevRegEvents | Group-Object -Property Id)) { 131 | $possibleErrors += New-AnalyzeResult -TestName "EventLog-WorkplaceJoin" -Type ($UsrDevRegEvent.Group[0].LevelDisplayName) -Issue "EventId: $($UsrDevRegEvent.Name)`n$($UsrDevRegEvent.Group[0].Message)" -PossibleCause "" 132 | } 133 | 134 | } 135 | # Connectifity Tests 136 | $isVerbose = $VerbosePreference -eq 'Continue' 137 | 138 | $data = New-Object System.Collections.Generic.List[System.Collections.Hashtable] 139 | 140 | # https://docs.microsoft.com/en-us/azure/active-directory/devices/hybrid-azuread-join-manual-steps 141 | 142 | $data.Add(@{ TestUrl = 'https://enterpriseregistration.windows.net'; ExpectedStatusCode = 404; PerformBluecoatLookup = $PerformBluecoatLookup; Verbose = $isVerbose }) 143 | $data.Add(@{ TestUrl = 'https://login.microsoftonline.com'; IgnoreCertificateValidationErrors = $false; PerformBluecoatLookup = $PerformBluecoatLookup; Verbose = $isVerbose }) 144 | $data.Add(@{ TestUrl = 'https://device.login.microsoftonline.com'; IgnoreCertificateValidationErrors = $true; PerformBluecoatLookup = $PerformBluecoatLookup; Verbose = $isVerbose }) 145 | $data.Add(@{ TestUrl = 'https://autologon.microsoftazuread-sso.com'; ExpectedStatusCode = 404; Description = 'URL required for Seamless SSO'; IgnoreCertificateValidationErrors = $true; PerformBluecoatLookup = $PerformBluecoatLookup; Verbose = $isVerbose }) 146 | 147 | $results = New-Object System.Collections.Generic.List[pscustomobject] 148 | 149 | $data | ForEach-Object { 150 | $connectivity = Get-HttpConnectivity @_ 151 | $results.Add($connectivity) 152 | if ($connectivity.Blocked -eq $true) { 153 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Error" -Issue "Connection blocked `n $($connectivity)" -PossibleCause "Firewall is blocking connection to '$($connectivity.UnblockUrl)'." 154 | } 155 | if ($connectivity.Resolved -eq $false) { 156 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Error" -Issue "DNS name not resolved `n $($connectivity)" -PossibleCause "DNS server not correctly configured." 157 | } 158 | if ($connectivity.ExpectedStatusCode -notcontains $connectivity.ActualStatusCode) { 159 | if($connectivity.ActualStatusCode -eq 407){ 160 | $Cause = "Keep in mind that the proxy has to be set in WinHTTP.`nWindows 1709 and newer: Set the proxy by using netsh or WPAD. --> https://docs.microsoft.com/en-us/windows/desktop/WinHttp/winhttp-autoproxy-support `nWindows 1709 and older: Set the proxy by using 'netsh winhttp set proxy ?' --> https://blogs.technet.microsoft.com/netgeeks/2018/06/19/winhttp-proxy-settings-deployed-by-gpo/ " 161 | } else { 162 | $Cause = "Interfering Proxy server can change HTTP status codes." 163 | } 164 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Error" -Issue "Returned HTTP Status code '$($connectivity.ActualStatusCode)' is not expected '$($connectivity.ExpectedStatusCode)'`n $($connectivity)" -PossibleCause $Cause 165 | } 166 | if ($null -ne $connectivity.ServerCertificate -and $connectivity.ServerCertificate.HasError) { 167 | $possibleErrors += New-AnalyzeResult -TestName "Connectivity" -Type "Error" -Issue "Certificate Error when connecting to $($connectivity.TestUrl)`n $(($connectivity.ServerCertificate))" -PossibleCause "Interfering Proxy server can change Certificate or not the Root Certificate is not trusted." 168 | } 169 | } 170 | 171 | # No errors detected, return success message 172 | if ($possibleErrors.Count -eq 0) { 173 | $possibleErrors += New-AnalyzeResult -TestName "All" -Type Information -Issue "All tests went through successfully. $(if(-not $IncludeEventLog){'You can try to run the command again with the -IncludeEventLog parameter.'})" -PossibleCause "" 174 | } 175 | 176 | return $possibleErrors 177 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Invoke-AnalyzeMDMEnrollmentStatus.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-AnalyzeMDMEnrollmentStatus { 2 | <# 3 | .Synopsis 4 | Analyzes current status of the device regarding Intune/MDM enrollment. 5 | 6 | .Description 7 | Analyzes current status of the device regarding Intune/MDM enrollment. 8 | 9 | Returns array of Messages with four properties: 10 | 11 | - Testname: Name of the Tets 12 | - Type: Information, Warning or Error 13 | - Issue: Description of the issue 14 | - Possible Cause: Tips on how to solve the issue. 15 | 16 | .Parameter IncludeEventLog 17 | By specifying this command also the most relevant Windows Event Log entries from the last 10 Minutes related to MDMe Enrollment are included in the Output of this CmdLet. 18 | 19 | .Parameter UPNDomain 20 | If you specify the UPN Domain od you users also the DNS Cnames are checked. Specify just the domain like "contoso.com". 21 | 22 | .Example 23 | # Displays a deep analyisis of the currently found issues in the system. 24 | Invoke-AnalyzeMDMIntuneEnrollmentStatus 25 | 26 | .Example 27 | # Displays a deep analyisis of the currently found issues in the system including DNS analysis. 28 | Invoke-AnalyzeMDMIntuneEnrollmentStatus -UPNDomain "contoso.com" 29 | #> 30 | param( 31 | [switch]$IncludeEventLog, 32 | [string]$UPNDomain 33 | ) 34 | $mdmstatus = Get-MDMEnrollmentStatus 35 | $possibleErrors = @() 36 | if($null -eq $mdmstatus){ 37 | $possibleErrors += New-AnalyzeResult -TestName "MDM Enrollment Regkeys" -Type Error -Issue "We could not locate MDM enrollment registry key under HKLM:\SOFTWARE\Microsoft\Enrollments." -PossibleCause "Try starting enrollment again. Xou can start MDM enrollment by executing 'ms-device-enrollment:?mode=mdm'." 38 | } else { 39 | if($mdmstatus.EnrollmentState -eq 0 -or $mdmstatus.EnrollmentType -eq 0){ 40 | $possibleErrors += New-AnalyzeResult -TestName "MDM Enrollment Regkeys" -Type Error -Issue "The enrollment has not yet started because Enrollment Type or EnrollmentState is still 0 in the registry($($mdmstatus.PSPath))." -PossibleCause "Try starting enrollment again. Xou can start MDM enrollment by executing 'ms-device-enrollment:?mode=mdm'." 41 | } 42 | } 43 | $dsregstatus = Get-DsRegStatus 44 | if($dsregstatus.AzureAdJoined -ne "YES"){ 45 | $possibleErrors += New-AnalyzeResult -TestName "Azure AD Join" -Type Warning -Issue "The device is not Azure AD Joined or Hybrid registered. Therefore auto enrollment will not work. If you do the enrollment manually, then you can ignore this warning." -PossibleCause "Try analysing the Azure AD Hybrid Join by using Invoke-AnalyzeHybridJoinStatus." 46 | } 47 | if(-not [String]::IsNullOrWhiteSpace($UPNDomain)){ 48 | $dns = Resolve-DnsName "EnterpriseEnrollment.$UPNDomain" -DnsOnly 49 | if($dns[0].NameHost -ne "EnterpriseEnrollment-s.manage.microsoft.com"){ 50 | $possibleErrors += New-AnalyzeResult -TestName "DNSCheck" -Type Warning -Issue "The DNS CName 'EnterpriseEnrollment.$UPNDomain' is not pointing to 'EnterpriseEnrollment-s.manage.microsoft.com'. This is not required for Autoenrollment, but without it the servername has to be entered during a manual enrollment to Intune." -PossibleCause "Add the CName in your DNS Zone." 51 | } 52 | $dns = Resolve-DnsName "EnterpriseRegistration.$UPNDomain" -DnsOnly 53 | if($dns[0].NameHost -ne "EnterpriseRegistration.windows.net"){ 54 | $possibleErrors += New-AnalyzeResult -TestName "DNSCheck" -Type Warning -Issue "The DNS CName 'EnterpriseRegistration.$UPNDomain' is not pointing to 'EnterpriseRegistration.windows.net'. This is not required for Autoenrollment, but without it the servername has to be entered during a manual enrollment to Intune." -PossibleCause "Add the CName in your DNS Zone." 55 | } 56 | } 57 | $AutoEnrollTask = Get-ScheduledTask -TaskName "Schedule created by enrollment client for automatically enrolling in MDM from AAD" -ErrorAction SilentlyContinue 58 | if($null -eq $AutoEnrollTask -and $dsregstatus.DomainJoined -eq "YES"){ 59 | $possibleErrors += New-AnalyzeResult -TestName "Scheduled Task" -Type Warning -Issue "The task for auto enrollment could not be found in the Windows Event log '\Microsoft\Windows\EnterpriseMgmt'." -PossibleCause "Please check if automatic enrollment is configured by GPO 'https://docs.microsoft.com/en-us/windows/client-management/mdm/enroll-a-windows-10-device-automatically-using-group-policy#configure-the-auto-enrollment-for-a-group-of-devices'" 60 | } 61 | # Analyze Eventlogs 62 | if($IncludeEventLog){ 63 | $MDMEvents = Get-WinEvent -LogName "Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin" | Where-Object { ($_.LevelDisplayName -eq "Error" -or $_.LevelDisplayName -eq "Warning") -and $_.TimeCreated -gt [DateTime]::Now.AddMinutes(-10) } 64 | foreach($MDMEvent in ($MDMEvents | Group-Object -Property Id)){ 65 | $possibleErrors += New-AnalyzeResult -TestName "EventLog-WorkplaceJoin" -Type ($MDMEvent.Group[0].LevelDisplayName) -Issue "EventId: $($MDMEvent.Name)`n$($MDMEvent.Group[0].Message)" -PossibleCause "" 66 | } 67 | } 68 | 69 | # No errors detected, return success message 70 | if($possibleErrors.Count -eq 0){ 71 | $possibleErrors += New-AnalyzeResult -TestName "All" -Type Information -Issue "All tests went through successfully." -PossibleCause "" 72 | } 73 | 74 | return $possibleErrors 75 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Invoke-IntuneCleanup.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | This script performs a cleanup for duplicated device entries in Microsoft Intune based on the serial number. 4 | 5 | .DESCRIPTION 6 | The script retrieves all devices from Intune and elaborates all duplicated devices based on the serial number. Only the newest device (Last Synced) will stay in the environment. 7 | 8 | .EXAMPLE 9 | Invoke-IntuneCleanup -Whatif | Out-GridView -OutputMode Multiple | foreach-Object { Remove-DeviceManagement_ManagedDevices -managedDeviceId $_.id } 10 | 11 | Retrieves duplicate devices and displays them first in a Out-Gridview, to select the devices which should be removed. 12 | 13 | .EXAMPLE 14 | Invoke-IntuneCleanup 15 | 16 | This command automatically removes duplicated objects based on the serial number. 17 | 18 | .NOTES 19 | Version: 1.0.0 20 | Author: Thomas Kurth 21 | Creation Date: 14.9.2019 22 | Purpose/Change: Initial script development 23 | 24 | .LINK 25 | https://www.wpninjas.ch/2019/09/cleanup-duplicated-devices-in-intune/ 26 | 27 | #> 28 | 29 | function Invoke-IntuneCleanup { 30 | [CmdletBinding(SupportsShouldProcess=$True,ConfirmImpact = 'High')] 31 | Param() 32 | Begin { 33 | Write-Verbose "Checking Intune Connection" 34 | try{ 35 | $null = Connect-MSGraph 36 | }catch{ 37 | Throw "Not authenticated. Please use the `"Connect-MSGraph`" command to authenticate first or if required install the Microsoft.Graph.Intune PSModule from the PSGallery." 38 | } 39 | } 40 | Process { 41 | $devices = Get-IntuneManagedDevice 42 | Write-Verbose "Found $($devices.Count) devices." 43 | $deviceGroups = $devices | Where-Object { -not [String]::IsNullOrWhiteSpace($_.serialNumber) } | Group-Object -Property serialNumber 44 | $duplicatedDevices = $deviceGroups | Where-Object {$_.Count -gt 1 } 45 | Write-Verbose "Found $($duplicatedDevices.Count) serialNumbers with duplicated entries" 46 | foreach($duplicatedDevice in $duplicatedDevices){ 47 | # Find device which is the newest. 48 | $newestDevice = $duplicatedDevice.Group | Sort-Object -Property lastSyncDateTime -Descending | Select-Object -First 1 49 | Write-Verbose "Serial $($duplicatedDevice.Name)" 50 | Write-Verbose "# Keep $($newestDevice.deviceName) $($newestDevice.lastSyncDateTime)" 51 | foreach($oldDevice in ($duplicatedDevice.Group | Sort-Object -Property lastSyncDateTime -Descending | Select-Object -Skip 1)){ 52 | Write-Verbose "# Remove $($oldDevice.deviceName) $($oldDevice.lastSyncDateTime)" 53 | if($WhatIfPreference){ 54 | $oldDevice 55 | } else { 56 | if ($PSCmdlet.ShouldProcess("Intune Device $($oldDevice.id)",'Remove')) { 57 | Remove-DeviceManagement_ManagedDevices -managedDeviceId $oldDevice.id 58 | } 59 | } 60 | } 61 | } 62 | } 63 | End { 64 | } 65 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Functions/Reset-MDMEnrollmentStatus.ps1: -------------------------------------------------------------------------------- 1 | function Reset-MDMEnrollmentStatus { 2 | <# 3 | .Synopsis 4 | Resets Windows 10 MDM Enrollment Status. 5 | 6 | .Description 7 | If you get an error upon trying to register a Windows computer that the device was already enrolled, but you are unable or have already unenrolled the device, you may have a fragment of device enrollment configuration in the registry. 8 | 9 | Reset done according to https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/operations/configure-device-based-conditional-access-on-premises#troubleshooting 10 | 11 | .Example 12 | # Resets the Device Enrollment state and allows to rerun the MDM enrollment Wizard 13 | Reset-MDMEnrollmentStatus 14 | #> 15 | [CmdletBinding(SupportsShouldProcess)] 16 | param() 17 | if(-not (Get-IsAdmin)){ 18 | throw "Access Denied: The cmdlet needs to be executed with administrator priviledges." 19 | } 20 | #Locate correct Enrollment Key 21 | $EnrollmentKey = Get-Item -Path HKLM:\SOFTWARE\Microsoft\Enrollments\* | Get-ItemProperty | Where-Object -FilterScript {$null -ne $_.UPN} 22 | if ($PSCmdlet.ShouldProcess("Would you like to reset EnrollmentStatus to 0?")) { 23 | Set-ItemProperty -Path $EnrollmentKey.PSPath -Name EnrollmentType -Value 0 -Force 24 | } 25 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Internal/Get-AzureEndpointExpectedResult.ps1: -------------------------------------------------------------------------------- 1 | function Get-AzureEndpointExpectedResult{ 2 | <# 3 | .Synopsis 4 | Returns the expected result and SSL error for a specific endpoint. 5 | 6 | .Description 7 | Returns the expected result and SSL error for a specific endpoint. 8 | 9 | .Example 10 | Get-AzureEndpointExpectedResult -Url "http://*.contoso.com" -Path "PathToModule" 11 | 12 | #> 13 | [OutputType([PSCustomObject])] 14 | [CmdletBinding()] 15 | param( 16 | [String]$Url, 17 | [String]$Path, 18 | [String]$TestType 19 | ) 20 | $returnValue = $null 21 | Write-Verbose "Try to get expected connectivity result for '$Url' from file '$Path\Data\AzureEndpointExpectedResults.json'." 22 | try{ 23 | $ExpectedResult = Get-Content -Path "$Path\Data\AzureEndpointExpectedResults.json" -ErrorAction Stop 24 | $ExpectedResultObjs = $ExpectedResult | ConvertFrom-Json 25 | foreach($ExpectedResultObj in $ExpectedResultObjs){ 26 | if($ExpectedResultObj.UnblockUrl -eq $Url){ 27 | $returnValue = $ExpectedResultObj 28 | break 29 | } 30 | } 31 | } catch { 32 | Write-Warning "Could not find '$Path\Data\AzureEndpointExpectedResults.json', failed to get expected connectifity results." 33 | } 34 | 35 | if($null -eq $returnValue){ 36 | if($TestType -eq "HTTP"){ 37 | Write-Warning "Using default Expected Result Http Status 200 without SSL validation for url $($url)." 38 | $returnValue = [PSCustomObject]@{ UnblockUrl = $Url;ActualStatusCode = 200; HasError = $true } 39 | } else { 40 | Write-Warning "Using default Expected Result Tcp Status 1 $($url)." 41 | $returnValue = [PSCustomObject]@{ UnblockUrl = $Url;ActualStatusCode = 1; HasError = $true } 42 | } 43 | } 44 | return $returnValue 45 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Internal/Get-AzureO365UrlEndpoint.ps1: -------------------------------------------------------------------------------- 1 | function Get-AzureO365UrlEndpoint{ 2 | <# 3 | .Synopsis 4 | Returns list of Azure/O365 endpoints from the official Microsoft webservice. 5 | 6 | .Description 7 | Try loading the actual list of Azure/O365 endpoints from the official Microsoft webservice. If not possible it will used a cached version. If an online version can be retriefed and the script is executed with administrative permission it also updates the local cache. 8 | 9 | .Example 10 | Get-AzureO365UrlEndpoint 11 | 12 | #> 13 | [OutputType([PSCustomObject[]])] 14 | [CmdletBinding()] 15 | param( 16 | [String] 17 | $Path 18 | ) 19 | $Endpoints = Invoke-WebRequest -Uri "https://endpoints.office.com/endpoints/worldwide?clientrequestid=$(New-Guid)" 20 | if($Endpoints.StatusCode -ne 200){ 21 | Write-Error "Error downloading the actual endpoint list ($($Endpoints.StatusDescription) - $($Endpoints.StatusCode)) `n https://endpoints.office.com" -ErrorAction Continue 22 | Write-Warning "Try using cached endpoint list" 23 | 24 | try{ 25 | $AzureEndpointCache = Get-Content -Path "$Path\Data\AzureEndpointCache.json" -ErrorAction Stop 26 | $EndpointsObjs = $AzureEndpointCache | ConvertFrom-Json 27 | } catch { 28 | throw "Could not find '$Path\Data\AzureEndpointCache.json, failed to load azure endpoints for connectivity tests." 29 | } 30 | } else { 31 | $EndpointsObjs = $Endpoints.Content | ConvertFrom-Json 32 | Write-Verbose "Successfully retrieved $($EndpointsObjs.Length) Endpoints from online source." 33 | if(Get-IsAdmin){ 34 | Write-Verbose "Function is executed as Administrator, therefore trying to update local cache file." 35 | Out-File -FilePath "$Path\Data\AzureEndpointCache.json" -InputObject $Endpoints.content -Force 36 | } 37 | } 38 | return $EndpointsObjs 39 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Internal/Get-InstalledApplication.ps1: -------------------------------------------------------------------------------- 1 | Function Get-InstalledApplication { 2 | <# 3 | .SYNOPSIS 4 | Retrieves information about all installed applications. 5 | .DESCRIPTION 6 | Retrieves information about all installed applications by querying the registry. 7 | Returns information about application publisher, name & version, product code, uninstall string, install source, location, date, and application architecture. 8 | 9 | .EXAMPLE 10 | Get-InstalledApplication 11 | #> 12 | [OutputType([System.Object[]])] 13 | [CmdletBinding()] 14 | param() 15 | [string[]]$regKeyApplications = 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall','HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' 16 | ## Enumerate the installed applications from the registry for applications that have the "DisplayName" property 17 | [psobject[]]$regKeyApplication = @() 18 | ForEach ($regKey in $regKeyApplications) { 19 | If (Test-Path -LiteralPath $regKey -ErrorAction 'SilentlyContinue') { 20 | [psobject[]]$UninstallKeyApps = Get-ChildItem -LiteralPath $regKey -ErrorAction 'SilentlyContinue' 21 | ForEach ($UninstallKeyApp in $UninstallKeyApps) { 22 | Try { 23 | [psobject]$regKeyApplicationProps = Get-ItemProperty -LiteralPath $UninstallKeyApp.PSPath -ErrorAction 'Stop' 24 | If ($regKeyApplicationProps.DisplayName) { [psobject[]]$regKeyApplication += $regKeyApplicationProps } 25 | } 26 | Catch{ 27 | Write-Warning "Unable to enumerate properties from registry key path [$($UninstallKeyApp.PSPath)]." 28 | Continue 29 | } 30 | } 31 | } 32 | } 33 | 34 | ## Create a custom object with the desired properties for the installed applications and sanitize property details 35 | [psobject[]]$installedApplication = @() 36 | ForEach ($regKeyApp in $regKeyApplication) { 37 | Try { 38 | [string]$appDisplayName = '' 39 | [string]$appDisplayVersion = '' 40 | [string]$appPublisher = '' 41 | 42 | ## Remove any control characters which may interfere with logging and creating file path names from these variables 43 | $appDisplayName = $regKeyApp.DisplayName -replace '[^\u001F-\u007F]','' 44 | $appDisplayVersion = $regKeyApp.DisplayVersion -replace '[^\u001F-\u007F]','' 45 | $appPublisher = $regKeyApp.Publisher -replace '[^\u001F-\u007F]','' 46 | 47 | ## Determine if application is a 64-bit application 48 | [boolean]$Is64BitApp = If (($is64Bit) -and ($regKeyApp.PSPath -notmatch '^Microsoft\.PowerShell\.Core\\Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node')) { $true } Else { $false } 49 | 50 | $installedApplication += New-Object -TypeName 'PSObject' -Property @{ 51 | UninstallSubkey = $regKeyApp.PSChildName 52 | ProductCode = If ($regKeyApp.PSChildName -match $MSIProductCodeRegExPattern) { $regKeyApp.PSChildName } Else { [string]::Empty } 53 | DisplayName = $appDisplayName 54 | DisplayVersion = $appDisplayVersion 55 | UninstallString = $regKeyApp.UninstallString 56 | InstallSource = $regKeyApp.InstallSource 57 | InstallLocation = $regKeyApp.InstallLocation 58 | InstallDate = $regKeyApp.InstallDate 59 | Publisher = $appPublisher 60 | Is64BitApplication = $Is64BitApp 61 | } 62 | } 63 | Catch { 64 | Write-Error "Failed to resolve application details from registry for [$appDisplayName]. $($_.Exception)" 65 | Continue 66 | } 67 | } 68 | 69 | Write-Information "Found $($installedApplication.Count) Apps." 70 | return $installedApplication 71 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Internal/Get-IsAdmin.ps1: -------------------------------------------------------------------------------- 1 | function Get-IsAdmin{ 2 | <# 3 | .Synopsis 4 | Returns $true if the script is executed with administrator priviledge, false if not. 5 | 6 | .Description 7 | Returns $true if the script is executed with administrator priviledge, false if not. 8 | 9 | .Example 10 | Get-IsAdmin 11 | 12 | #> 13 | [OutputType([bool])] 14 | [CmdletBinding()] 15 | param() 16 | $CurrentUser = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()) 17 | $IsAdmin = $CurrentUser.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) 18 | Write-Verbose "Detected that the current session is$(if($IsAdmin){ " not"}) running with administrator priviledges." 19 | return $IsAdmin 20 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Internal/Get-NtpTime.ps1: -------------------------------------------------------------------------------- 1 | Function Get-NtpTime ( [String]$NTPServer ) 2 | { 3 | # Build NTP request packet. We'll reuse this variable for the response packet 4 | $NTPData = New-Object byte[] 48 # Array of 48 bytes set to zero 5 | $NTPData[0] = 27 # Request header: 00 = No Leap Warning; 011 = Version 3; 011 = Client Mode; 00011011 = 27 6 | 7 | # Open a connection to the NTP service 8 | $Socket = New-Object Net.Sockets.Socket ( 'InterNetwork', 'Dgram', 'Udp' ) 9 | $Socket.SendTimeOut = 2000 # ms 10 | $Socket.ReceiveTimeOut = 2000 # ms 11 | $Socket.Connect( $NTPServer, 123 ) 12 | 13 | # Make the request 14 | $Null = $Socket.Send( $NTPData ) 15 | $Null = $Socket.Receive( $NTPData ) 16 | 17 | # Clean up the connection 18 | $Socket.Shutdown( 'Both' ) 19 | $Socket.Close() 20 | 21 | # Extract relevant portion of first date in result (Number of seconds since "Start of Epoch") 22 | $Seconds = [BitConverter]::ToUInt32( $NTPData[43..40], 0 ) 23 | 24 | # Add them to the "Start of Epoch", convert to local time zone, and return 25 | ( [datetime]'1/1/1900' ).AddSeconds( $Seconds ).ToLocalTime() 26 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Internal/Get-UrlWildCardLookup.ps1: -------------------------------------------------------------------------------- 1 | function Get-UrlWildCardLookup{ 2 | <# 3 | .Synopsis 4 | tryes to find a static URL for a Wildcard URL from the . 5 | 6 | .Description 7 | Returns $true if the script is executed with administrator priviledge, false if not. 8 | 9 | .Example 10 | Get-UrlWildCardLookup -Url "*.contoso.com" 11 | 12 | #> 13 | [OutputType([String[]])] 14 | [CmdletBinding()] 15 | param( 16 | [String]$Url, 17 | [String]$Path 18 | ) 19 | 20 | 21 | [String[]]$StaticUrls = @() 22 | Write-Verbose "Try to resolve '$Url' Wildcard Url to an static url from file '$Path\Data\UrlWildcardLookup.json'." 23 | try{ 24 | $AddToCache = $true 25 | $WildCardJSON = Get-Content -Path "$Path\Data\UrlWildcardLookup.json" -ErrorAction Stop 26 | $WildCardJSONObjs = $WildCardJSON | ConvertFrom-Json 27 | foreach($WildCardJSONObj in $WildCardJSONObjs){ 28 | if($WildCardJSONObj.Wildcard -eq $Url){ 29 | if($null -ne $WildCardJSONObj.static){ 30 | foreach($UrlPart in $WildCardJSONObj.static.Split(",")){ 31 | if(-not [String]::IsNullOrWhiteSpace($UrlPart)){ 32 | if($UrlPart -match "http*"){ 33 | $StaticUrls += $UrlPart 34 | Write-Verbose "Resolved URL $UrlPart" 35 | } else { 36 | $StaticUrls += $Url -replace "\*",$UrlPart 37 | Write-Verbose "Resolved URL $($Url -replace "\*",$UrlPart)" 38 | } 39 | } 40 | } 41 | } else { 42 | $AddToCache = $false 43 | Write-Verbose "Found a matching URL, but there are no static entries for '$Url' Url. Please add them in the '$Path\Data\UrlWildcardLookup.json'." 44 | } 45 | } 46 | } 47 | if($StaticUrls.Length -eq 0 -and $AddToCache){ 48 | Write-Warning "Could not find a matching static URL for the suplied wildcard '$Url' Url." 49 | $WildCardJSONObjs += [PSCustomObject]@{ Wildcard = $Url; static = $null } 50 | Out-File -FilePath "$Path\Data\UrlWildcardLookup.json" -InputObject ($WildCardJSONObjs | ConvertTo-Json) -Force 51 | } 52 | } catch { 53 | Write-Warning "Could not find '$Path\Data\UrlWildcardLookup.json', failed to convert wildcard into static url. $($_.Exception.Message)" 54 | 55 | } 56 | return [String[]]$StaticUrls 57 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Internal/Invoke-TranslateAppStatus.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-TranslateAppStatus { 2 | <# 3 | .SYNOPSIS 4 | This function translates the Intune MSI App Install status in a readable string. 5 | .DESCRIPTION 6 | This function translates the Intune MSI App Install status in a readable string. 7 | 8 | .EXAMPLE 9 | Invoke-TranslateAppStatus 10 | #> 11 | [OutputType([String])] 12 | [CmdletBinding()] 13 | param( 14 | [Int]$Id 15 | ) 16 | switch($Id){ 17 | 10 {"Initialized"} 18 | 20 {"Download in Progress"} 19 | 25 {"Pending Download Retry"} 20 | 30 {"Download Failed"} 21 | 40 {"Download Completed"} 22 | 48 {"Pending User Session"} 23 | 50 {"Enforcement in Progress"} 24 | 55 {"Pending Enforcement Retry"} 25 | 60 {"Enforcement Failed"} 26 | 70 {"Enforcement Completed"} 27 | } 28 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Internal/Invoke-TranslateMDMEnrollmentType.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-TranslateMDMEnrollmentType { 2 | <# 3 | .SYNOPSIS 4 | This function translates the MDM Enrollment Type in a readable string. 5 | .DESCRIPTION 6 | This function translates the MDM Enrollment Type in a readable string. 7 | 8 | .EXAMPLE 9 | Invoke-TranslateMDMEnrollmentType 10 | #> 11 | [OutputType([String])] 12 | [CmdletBinding()] 13 | param( 14 | [Int]$Id 15 | ) 16 | switch($Id){ 17 | 0 {"Not enrolled"} 18 | 6 {"MDM enrolled"} 19 | 13 {"Azure AD joined"} 20 | } 21 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/Internal/New-AnalyzeResult.ps1: -------------------------------------------------------------------------------- 1 | function New-AnalyzeResult{ 2 | <# 3 | .Synopsis 4 | Creates an new analysis object which will be returned by most of the analytics functions in the module. 5 | 6 | .Description 7 | Returns an object with the following properties: 8 | - Testname 9 | - Type 10 | - Issue 11 | - PossibleCause 12 | 13 | .Example 14 | # New Error Result 15 | New-AnalyzeResult -Testname "AD Check" -Type Error -Issue "Description of the found Issue" -PossibleCause "Description of possible solutions related to the Issue" 16 | 17 | #> 18 | [OutputType([PSObject])] 19 | [CmdletBinding(SupportsShouldProcess)] 20 | param( 21 | [Parameter(Mandatory=$true)] 22 | [String]$TestName, 23 | [ValidateSet("Error","Warning","Information")] 24 | [String]$Type = "Information", 25 | [String]$Issue, 26 | [String]$PossibleCause 27 | 28 | ) 29 | $newResolution = New-Object -TypeName PSObject 30 | Add-Member -InputObject $newResolution -MemberType NoteProperty -Name "Testname" -Value $TestName 31 | Add-Member -InputObject $newResolution -MemberType NoteProperty -Name "Type" -Value $Type 32 | Add-Member -InputObject $newResolution -MemberType NoteProperty -Name "Issue" -Value $Issue 33 | Add-Member -InputObject $newResolution -MemberType NoteProperty -Name "PossibleCause" -Value $PossibleCause 34 | if ($PSCmdlet.ShouldProcess("Should return Object?")) { 35 | return $newResolution 36 | } 37 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/ModernWorkplaceClientCenter.psd1: -------------------------------------------------------------------------------- 1 | # 2 | # Module manifest for module 'PSGet_ModernWorkplaceClientCenter' 3 | # 4 | # Generated by: Thomas Kurth 5 | # 6 | # Generated on: 02.06.2020 7 | # 8 | 9 | @{ 10 | 11 | # Script module or binary module file associated with this manifest. 12 | RootModule = 'ModernWorkplaceClientCenter.psm1' 13 | 14 | # Version number of this module. 15 | ModuleVersion = '0.1.17' 16 | 17 | # Supported PSEditions 18 | # CompatiblePSEditions = @() 19 | 20 | # ID used to uniquely identify this module 21 | GUID = '10491a0d-b6a4-4c17-a385-e3b24fe80aa9' 22 | 23 | # Author of this module 24 | Author = 'Thomas Kurth' 25 | 26 | # Company or vendor of this module 27 | CompanyName = 'Thomas Kurth' 28 | 29 | # Copyright statement for this module 30 | Copyright = '(c) 2019 Thomas Kurth. All rights reserved.' 31 | 32 | # Description of the functionality provided by this module 33 | Description = 'The Modern Workplace Client Center Module provides functions to troubleshoot Microsoft Intune on a Windows 10 client in a modern managed environment. Th initial version mainly allows troubleshooting Azure AD Hybrid Join.' 34 | 35 | # Minimum version of the Windows PowerShell engine required by this module 36 | PowerShellVersion = '5.0' 37 | 38 | # Name of the Windows PowerShell host required by this module 39 | # PowerShellHostName = '' 40 | 41 | # Minimum version of the Windows PowerShell host required by this module 42 | # PowerShellHostVersion = '' 43 | 44 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 45 | # DotNetFrameworkVersion = '' 46 | 47 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 48 | # CLRVersion = '' 49 | 50 | # Processor architecture (None, X86, Amd64) required by this module 51 | # ProcessorArchitecture = '' 52 | 53 | # Modules that must be imported into the global environment prior to importing this module 54 | # RequiredModules = @() 55 | 56 | # Assemblies that must be loaded prior to importing this module 57 | # RequiredAssemblies = @() 58 | 59 | # Script files (.ps1) that are run in the caller's environment prior to importing this module. 60 | # ScriptsToProcess = @() 61 | 62 | # Type files (.ps1xml) to be loaded when importing this module 63 | # TypesToProcess = @() 64 | 65 | # Format files (.ps1xml) to be loaded when importing this module 66 | # FormatsToProcess = @() 67 | 68 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess 69 | NestedModules = @('NestedModules/HttpConnectivityTester/HttpConnectivityTester.psm1', 70 | 'NestedModules/TcpConnectivityTester/TcpConnectivityTester.psm1') 71 | 72 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. 73 | FunctionsToExport = 'Get-BCStatusDetailed', 'Get-DsRegStatus', 'Get-MDMDeviceOwnership', 74 | 'Get-MDMEnrollmentStatus', 'Get-MDMMsiApp', 'Get-MDMPSScriptStatus', 75 | 'Get-SiteToZoneAssignment', 'Invoke-AnalyzeAzureConnectivity', 76 | 'Invoke-AnalyzeDeliveryOptimization', 77 | 'Invoke-AnalyzeHybridJoinStatus', 78 | 'Invoke-AnalyzeMDMEnrollmentStatus', 'Invoke-IntuneCleanup', 79 | 'Invoke-TestAutopilotNetworkEndpoint', 'Reset-MDMEnrollmentStatus' 80 | 81 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. 82 | CmdletsToExport = @() 83 | 84 | # Variables to export from this module 85 | # VariablesToExport = @() 86 | 87 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. 88 | AliasesToExport = @() 89 | 90 | # DSC resources to export from this module 91 | # DscResourcesToExport = @() 92 | 93 | # List of all modules packaged with this module 94 | # ModuleList = @() 95 | 96 | # List of all files packaged with this module 97 | # FileList = @() 98 | 99 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 100 | PrivateData = @{ 101 | 102 | PSData = @{ 103 | 104 | # Tags applied to this module. These help with module discovery in online galleries. 105 | Tags = 'Intune','Windows','DevOps' 106 | 107 | # A URL to the license for this module. 108 | LicenseUri = 'https://github.com/ThomasKur/ModernWorkplaceClientCenter/blob/master/LICENSE' 109 | 110 | # A URL to the main website for this project. 111 | ProjectUri = 'https://github.com/ThomasKur/ModernWorkplaceClientCenter' 112 | 113 | # A URL to an icon representing this module. 114 | IconUri = 'https://raw.githubusercontent.com/ThomasKur/ModernWorkplaceClientCenter/master/Logo/MWCC-Logo-512.png' 115 | 116 | # ReleaseNotes of this module 117 | ReleaseNotes = ' 0.1.17 - Bugfix Get-Dsregcmd 118 | 119 | * Regex change required to return every property. 120 | 121 | 122 | 123 | To see the complete history, checkout the Release Notes on Github' 124 | 125 | # Prerelease string of this module 126 | # Prerelease = '' 127 | 128 | # Flag to indicate whether the module requires explicit user acceptance for install/update 129 | # RequireLicenseAcceptance = $false 130 | 131 | # External dependent modules of this module 132 | # ExternalModuleDependencies = @() 133 | 134 | } # End of PSData hashtable 135 | 136 | } # End of PrivateData hashtable 137 | 138 | # HelpInfo URI of this module 139 | # HelpInfoURI = '' 140 | 141 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. 142 | # DefaultCommandPrefix = '' 143 | 144 | } 145 | 146 | -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/ModernWorkplaceClientCenter.psm1: -------------------------------------------------------------------------------- 1 | $functionFolders = @('Functions', 'Internal') 2 | 3 | # Importing all the Functions required for the module from the subfolders. 4 | ForEach ($folder in $functionFolders) { 5 | $folderPath = Join-Path -Path $PSScriptRoot -ChildPath $folder 6 | If (Test-Path -Path $folderPath) 7 | { 8 | Write-Verbose -Message "Importing from $folder" 9 | $functions = Get-ChildItem -Path $folderPath -Filter '*.ps1' 10 | ForEach ($function in $functions) 11 | { 12 | Write-Verbose -Message " Loading $($function.FullName)" 13 | . ($function.FullName) 14 | } 15 | } else { 16 | Write-Warning "Path $folderPath not found. Some parts of the module will not work." 17 | } 18 | } 19 | 20 | $HttpConnectivitytester = Get-Module -Name HttpConnectivityTester 21 | if($HttpConnectivitytester){ 22 | Write-Verbose -Message "HttpConnectivityTester module is loaded." 23 | } else { 24 | Write-Warning -Message "HttpConnectivityTester module is not loaded, trying to import it." 25 | Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath "NestedModules\HttpConnectivityTester\HttpConnectivityTester.psd1") 26 | } 27 | 28 | $TcpConnectivitytester = Get-Module -Name TcpConnectivityTester 29 | if($TcpConnectivitytester){ 30 | Write-Verbose -Message "TcpConnectivityTester module is loaded." 31 | } else { 32 | Write-Warning -Message "TcpConnectivityTester module is not loaded, trying to import it." 33 | Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath "NestedModules\TcpConnectivityTester\TcpConnectivityTester.psd1") 34 | } -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/NestedModules/HttpConnectivityTester/HttpConnectivityTester.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThomasKur/ModernWorkplaceClientCenter/05eb15ee9c2168ebf935a6521688268983506f00/PSModule/ModernWorkplaceClientCenter/NestedModules/HttpConnectivityTester/HttpConnectivityTester.psd1 -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/NestedModules/HttpConnectivityTester/HttpConnectivityTester.psm1: -------------------------------------------------------------------------------- 1 | Set-StrictMode -Version 4 2 | 3 | $rateLimitCount = 0 4 | $sleepSeconds = 5 * 60 5 | 6 | Function Get-ErrorMessage() { 7 | <# 8 | .SYNOPSIS 9 | Gets a formatted error message from an error record. 10 | 11 | .DESCRIPTION 12 | Gets a formatted error message from an error record. 13 | 14 | .EXAMPLE 15 | Get-ErrorMessage -ErrorRecords $_ 16 | #> 17 | [CmdletBinding()] 18 | [OutputType([string])] 19 | Param( 20 | [Parameter(Mandatory=$true, HelpMessage='The PowerShell error record object to get information from')] 21 | [ValidateNotNullOrEmpty()] 22 | [System.Management.Automation.ErrorRecord]$ErrorRecord 23 | ) 24 | Process { 25 | $msg = [System.Environment]::NewLine,'Exception Message: ',$ErrorRecord.Exception.Message -join '' 26 | 27 | if($null -ne $ErrorRecord.Exception.HResult) { 28 | $msg = $msg,[System.Environment]::NewLine,'Exception HRESULT: ',('{0:X}' -f $ErrorRecord.Exception.HResult),$ErrorRecord.Exception.HResult -join '' 29 | } 30 | 31 | if($null -ne $ErrorRecord.Exception.StackTrace) { 32 | $msg = $msg,[System.Environment]::NewLine,'Exception Stacktrace: ',$ErrorRecord.Exception.StackTrace -join '' 33 | } 34 | 35 | if ($null -ne ($ErrorRecord.Exception | Get-Member | Where-Object { $_.Name -eq 'WasThrownFromThrowStatement'})) { 36 | $msg = $msg,[System.Environment]::NewLine,'Explicitly Thrown: ',$ErrorRecord.Exception.WasThrownFromThrowStatement -join '' 37 | } 38 | 39 | if ($null -ne $ErrorRecord.Exception.InnerException) { 40 | if ($ErrorRecord.Exception.InnerException.Message -ne $ErrorRecord.Exception.Message) { 41 | $msg = $msg,[System.Environment]::NewLine,'Inner Exception: ',$ErrorRecord.Exception.InnerException.Message -join '' 42 | } 43 | 44 | if($null -ne $ErrorRecord.Exception.InnerException.HResult) { 45 | $msg = $msg,[System.Environment]::NewLine,'Inner Exception HRESULT: ',('{0:X}' -f $ErrorRecord.Exception.InnerException.HResult),$ErrorRecord.Exception.InnerException.HResult -join '' 46 | } 47 | } 48 | 49 | $msg = $msg,[System.Environment]::NewLine,'Call Site: ',$ErrorRecord.InvocationInfo.PositionMessage -join '' 50 | 51 | if ($null -ne ($ErrorRecord | Get-Member | Where-Object { $_.Name -eq 'ScriptStackTrace'})) { 52 | $msg = $msg,[System.Environment]::NewLine,"Script Stacktrace: ",$ErrorRecord.ScriptStackTrace -join '' 53 | } 54 | 55 | return $msg 56 | } 57 | } 58 | 59 | Function Get-BlueCoatSiteReview() { 60 | [CmdletBinding()] 61 | [OutputType([psobject])] 62 | Param ( 63 | [Parameter(Mandatory=$true, HelpMessage='The URL to get BlueCoat Site Review information for.')] 64 | [ValidateNotNullOrEmpty()] 65 | [Uri]$Url, 66 | 67 | [Parameter(Mandatory=$false, HelpMessage='The user agent.')] 68 | [ValidateNotNullOrEmpty()] 69 | [string]$UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36', 70 | 71 | [Parameter(Mandatory=$false, HelpMessage='Disable throttling.')] 72 | [switch]$NoThrottle 73 | ) 74 | 75 | if ($Url.OriginalString.ToLower().StartsWith('http://') -or $Url.OriginalString.ToLower().StartsWith('https://')) { 76 | $testUri = $Url 77 | } else { 78 | $testUri = [Uri]('http://{0}' -f $Url.OriginalString) 79 | } 80 | 81 | $newLine = [System.Environment]::NewLine 82 | 83 | $throttle = !$NoThrottle 84 | 85 | if ($throttle) { 86 | $rateLimitCount++ 87 | 88 | if($rateLimitCount -gt 10) { 89 | $nowTime = [DateTime]::Now 90 | $resumeTime = $nowTime.AddSeconds($sleepSeconds) 91 | 92 | Write-Verbose -Message ('Paused for {0} seconds. Current time: {1} Resume time: {2}' -f $sleepSeconds,$nowTime,$resumeTime) 93 | 94 | Start-Sleep -Seconds $sleepSeconds 95 | 96 | $nowTime = [DateTime]::Now 97 | 98 | Write-Verbose -Message ('Resumed at {0}' -f $nowTime) 99 | 100 | $rateLimitCount = 1 # needs to be 1 since BlueCoat Site Review API is called when exiting this if statement. If left at 0, then will hit the rate limit on successive calls to this cmdlet 101 | } 102 | } 103 | 104 | 105 | $uri = $testUri 106 | 107 | $proxyUri = [System.Net.WebRequest]::GetSystemWebProxy().GetProxy($uri) 108 | 109 | $params = @{ 110 | Uri = 'https://sitereview.bluecoat.com/resource/lookup'; 111 | Method = 'POST'; 112 | ProxyUseDefaultCredentials = (([string]$proxyUri) -ne $uri); 113 | UseBasicParsing = $true; 114 | UserAgent = $UserAgent 115 | ContentType = 'application/json'; 116 | Body = (@{url = $uri; captcha = ''} | ConvertTo-Json); 117 | Headers = @{Referer = 'https://sitereview.bluecoat.com'} ; 118 | Verbose = $false 119 | } 120 | 121 | if (([string]$proxyUri) -ne $uri) { 122 | $params.Add('Proxy',$proxyUri) 123 | } 124 | 125 | $ProgressPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue 126 | 127 | $statusCode = 0 128 | $statusDescription = '' 129 | 130 | try { 131 | $response = Invoke-WebRequest @params 132 | 133 | $statusCode = $response.StatusCode 134 | } catch [System.Net.WebException] { 135 | $statusCode = [int]$_.Exception.Response.StatusCode 136 | $statusDescription = $_.Exception.Response.StatusDescription 137 | } 138 | 139 | if ($statusCode -ne 200) { 140 | throw "BlueCoat Site Review REST API request failed. Status code: $statusCode Status description: $statusDescription" 141 | } 142 | 143 | $returnedJson = $response.Content 144 | 145 | #Write-Verbose -Message ('JSON: {0}' -f $returnedJson) 146 | 147 | $siteReview = $returnedJson | ConvertFrom-Json 148 | 149 | if ($siteReview.PSObject.Properties.Name -contains 'errorType') { 150 | throw ('Error retrieving Blue Coat data. Error Type: {0} Error Message: {1}' -f $siteReview.errorType, $siteReview.error) 151 | } 152 | 153 | $cats = @{} 154 | 155 | $siteReview.categorization | ForEach-Object { 156 | $link = ('https://sitereview.bluecoat.com/catdesc.jsp?catnum={0}' -f $_.num) 157 | $cats.Add($_.name,$link) 158 | } 159 | 160 | $dateMatched = $siteReview.rateDate -match 'Last Time Rated/Reviewed:\s*(.+)\s*{{.*' 161 | 162 | $lastRated = '' 163 | 164 | if($dateMatched -and $matches.Count -ge 2) { 165 | $lastRated = $matches[1].Trim() 166 | } 167 | 168 | $siteReviewObject = [pscustomobject]@{ 169 | SubmittedUri = $Uri; 170 | ReturnedUri = [System.Uri]$siteReview.url; 171 | Rated = $siteReview.unrated -eq 'false' 172 | LastedRated = $lastRated; 173 | Locked = $siteReview.locked -eq 'true'; 174 | LockMessage = if ($siteReview.locked -eq 'true') {[string]$siteReview.lockedMessage} else {''}; 175 | Pending = $siteReview.multiple -eq 'true'; 176 | PendingMessage = if ($siteReview.multiple -eq 'true') {[string]$siteReview.multipleMessage} else {''}; 177 | Categories = $cats; 178 | } 179 | 180 | Write-Verbose -Message ('{0}Rated: {1}{2}Last Rated: {3}{4}Locked: {5}{6}Lock Message: {7}{8}Pending: {9}{10}Pending Message: {11}{12}Categories: {13}{14}{15}' -f $newLine,$siteReviewObject.Rated,$newLine,$siteReviewObject.LastedRated,$newLine,$siteReviewObject.Locked,$newLine,$siteReviewObject.LockMessage,$newLine,$siteReviewObject.Pending,$newLine,$siteReviewObject.PendingMessage,$newLine,($siteReviewObject.Categories.Keys -join ','),$newLine,$newLine) 181 | 182 | return $siteReviewObject 183 | } 184 | 185 | Function Get-IPAddress() { 186 | <# 187 | .SYNOPSIS 188 | Gets the IP address(es) for a URL. 189 | 190 | .DESCRIPTION 191 | Gets the IP address(es) for a URL. 192 | 193 | .EXAMPLE 194 | Get-IPAddress -Url http://www.site.com 195 | #> 196 | [CmdletBinding()] 197 | [OutputType([string[]])] 198 | Param ( 199 | [Parameter(Mandatory=$true, HelpMessage='The URL to get the IP address for.')] 200 | [ValidateNotNullOrEmpty()] 201 | [System.Uri]$Url 202 | ) 203 | 204 | $addresses = [string[]]@() 205 | 206 | $dnsResults = $null 207 | 208 | $dnsResults = @(Resolve-DnsName -Name $Url.Host -NoHostsFile -Type A_AAAA -QuickTimeout -ErrorAction SilentlyContinue | Where-Object {$_.Type -eq 'A'}) 209 | 210 | $addresses = [string[]]@($dnsResults | ForEach-Object { try { $_.IpAddress } catch [System.Management.Automation.PropertyNotFoundException] {Write-Verbose "No IP in Object."} }) # IpAddress results in a PropertyNotFoundException when a URL is blocked upstream 211 | 212 | return [string[]](,$addresses) 213 | } 214 | 215 | Function Get-IPAlias() { 216 | <# 217 | .SYNOPSIS 218 | Gets DNS alias for a URL. 219 | 220 | .DESCRIPTION 221 | Gets DNS alias for a URL. 222 | 223 | .EXAMPLE 224 | Get-IPAlias -Url http://www.site.com 225 | #> 226 | [CmdletBinding()] 227 | [OutputType([string[]])] 228 | Param ( 229 | [Parameter(Mandatory=$true, HelpMessage='The URL to get the alias address for.')] 230 | [ValidateNotNullOrEmpty()] 231 | [System.Uri]$Url 232 | ) 233 | 234 | $aliases = [string[]]@() 235 | 236 | $dnsResults = $null 237 | 238 | $dnsResults = @(Resolve-DnsName -Name $Url.Host -NoHostsFile -QuickTimeout -ErrorAction SilentlyContinue | Where-Object { $_.Type -eq 'CNAME' }) 239 | 240 | #$aliases = [string[]]@($dnsResults | ForEach-Object { try { $_.NameHost } catch [System.Management.Automation.PropertyNotFoundException] {} }) # NameHost results in a PropertyNotFoundException when a URL is blocked upstream 241 | $aliases = [string[]]@($dnsResults | ForEach-Object { $_.NameHost }) 242 | 243 | return [string[]](,$aliases) 244 | } 245 | 246 | Function Get-CertificateErrorMessage() { 247 | <# 248 | .SYNOPSIS 249 | Gets certificate error messages for an HTTPS URL. 250 | 251 | .DESCRIPTION 252 | Gets certificate error messages for an HTTPS URL. 253 | 254 | .EXAMPLE 255 | Get-CertificateErrorMessage -Url http://www.site.com -Certificate $certificate -Chain $chain -PolicyError $policyError 256 | #> 257 | [CmdletBinding()] 258 | [OutputType([string])] 259 | Param( 260 | [Parameter(Mandatory=$true, HelpMessage='The URL to test')] 261 | [ValidateNotNullOrEmpty()] 262 | [Uri]$Url, 263 | 264 | [Parameter(Mandatory=$true, HelpMessage='The certificate')] 265 | [ValidateNotNull()] 266 | [Security.Cryptography.X509Certificates.X509Certificate]$Certificate, 267 | 268 | [Parameter(Mandatory=$true, HelpMessage='The certificate chain')] 269 | [ValidateNotNull()] 270 | $Chain, # had to drop [Security.Cryptography.X509Certificates.X509Chain] otherwise call to Get-CertificateErrorMessage fails with "Cannot process argument transformation on parameter 'Chain'. Cannot create object of type "System.Security.Cryptography.X509Certificates.X509Chain". "ChainContext" is a ReadOnly property." 271 | 272 | [Parameter(Mandatory=$true, HelpMessage='The SSL error')] 273 | [ValidateNotNull()] 274 | [Net.Security.SslPolicyErrors]$PolicyError 275 | ) 276 | 277 | $details = '' 278 | 279 | if($PolicyError -ne [Net.Security.SslPolicyErrors]::None) { 280 | switch ($PolicyError) { 281 | 'RemoteCertificateChainErrors' { 282 | 283 | if ($Chain.ChainElements.Count -gt 0 -and $Chain.ChainStatus.Count -gt 0) { 284 | if ($Chain.ChainElements.Count -gt 0 -or $Chain.ChainStatus.Count -gt 0) { 285 | Write-Verbose -Message ('Multiple remote certificate chain elements exist. ChainElement Count: {0} ChainStatus Count: {1}' -f $Chain.ChainElements.Count,$Chain.ChainStatus.Count) 286 | } 287 | 288 | #todo support more than one chain 289 | $element = $Chain.ChainElements[0] 290 | $status = $Chain.ChainStatus[0] 291 | $details = ('Certificate chain error. Error: {0} Reason: {1} Certificate: {2}' -f $status.Status, $status.StatusInformation,$element.Certificate.ToString($false)) 292 | } else { 293 | $details = ('Certificate chain error. Certificate: {0}' -f $Certificate.ToString($false)) 294 | } 295 | break 296 | } 297 | 'RemoteCertificateNameMismatch' { 298 | $cert = New-Object Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList $Certificate 299 | 300 | $sanExtension = $cert.Extensions | Where-Object { $_.Oid.FriendlyName -eq 'Subject Alternative Name' } 301 | 302 | if ($null -eq $sanExtension) { 303 | $subject = $cert.Subject.Split(',')[0].Replace('CN=', '') 304 | $details = ('Remote certificate name mismatch. Host: {0} Subject: {1}' -f $Url.Host,$subject) 305 | } else { 306 | $subject = $certificate.Subject.Split(',')[0].Replace('CN=', '') 307 | $asnData = New-Object Security.Cryptography.AsnEncodedData -ArgumentList $sanExtension.Oid,$sanExtension.RawData 308 | $sans = $asnData.Format($false).Replace('DNS Name=', '').Replace(',', '').Split(@(' '), [StringSplitOptions]::RemoveEmptyEntries) 309 | $details = ('Remote certificate name mismatch. Host: {0} Subject: {1} SANs: {2}' -f $Url.Host,$subject,($sans -join ', ')) 310 | } 311 | break 312 | } 313 | 'RemoteCertificateNotAvailable' { 314 | $details = 'Remote certificate not available.' 315 | } 316 | 'None' { 317 | break 318 | } 319 | default { 320 | $details = ('Unrecognized remote certificate error. {0}' -f $PolicyError) 321 | break 322 | } 323 | } 324 | } 325 | 326 | return $details 327 | } 328 | 329 | Function Get-HttpConnectivity() { 330 | <# 331 | .SYNOPSIS 332 | Gets HTTP connectivity information for a URL. 333 | 334 | .DESCRIPTION 335 | Gets HTTP connectivity information for a URL. 336 | 337 | .EXAMPLE 338 | Get-HttpConnectivity -TestUrl http://www.site.com 339 | 340 | .EXAMPLE 341 | Get-HttpConnectivity -TestUrl http://www.site.com -UrlPattern http://*.site.com 342 | 343 | .EXAMPLE 344 | Get-HttpConnectivity -TestUrl http://www.site.com -Method POST 345 | 346 | .EXAMPLE 347 | Get-HttpConnectivity -TestUrl http://www.site.com -ExpectedStatusCode 400 348 | 349 | .EXAMPLE 350 | Get-HttpConnectivity -TestUrl http://www.site.com -Description 'A site that does something' 351 | 352 | .EXAMPLE 353 | Get-HttpConnectivity -TestUrl http://www.site.com -UserAgent 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36'' 354 | 355 | .EXAMPLE 356 | Get-HttpConnectivity -TestUrl http://www.site.com -IgnoreCertificateValidationErrors 357 | 358 | .EXAMPLE 359 | Get-HttpConnectivity -TestUrl http://www.site.com -PerformBluecoatLookup 360 | #> 361 | [CmdletBinding()] 362 | [OutputType([void])] 363 | Param( 364 | [Parameter(Mandatory=$true, HelpMessage='The URL to test.')] 365 | [ValidateNotNullOrEmpty()] 366 | [Uri]$TestUrl, 367 | 368 | [Parameter(Mandatory=$false, HelpMessage='The URL pattern to unblock when the URL to unblock is not a literal URL.')] 369 | [ValidateNotNullOrEmpty()] 370 | [string]$UrlPattern, 371 | 372 | [Parameter(Mandatory=$false, HelpMessage="The HTTP method used to test the URL. Defaults to 'GET'.")] 373 | [ValidateNotNullOrEmpty()] 374 | [ValidateSet('HEAD','GET', 'POST', IgnoreCase=$true)] 375 | [string]$Method = 'GET', 376 | 377 | [Parameter(Mandatory=$false, HelpMessage='The HTTP status code expected to be returned. Defaults to 200.')] 378 | [ValidateNotNullOrEmpty()] 379 | [Int32[]]$ExpectedStatusCode = 200, 380 | 381 | [Parameter(Mandatory=$false, HelpMessage='A description of the connectivity test or purpose of the URL.')] 382 | [ValidateNotNullOrEmpty()] 383 | [string]$Description, 384 | 385 | [Parameter(Mandatory=$false, HelpMessage='The HTTP user agent. Defaults to the Chrome browser user agent.')] 386 | [ValidateNotNullOrEmpty()] 387 | [string]$UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36', 388 | 389 | [Parameter(Mandatory=$false, HelpMessage="Whether to ignore certificate validation errors so they don't affect the connectivity test. Some HTTPS endpoints are not meant to be accessed by a browser so the endpoint will not validate against browser security requirements.")] 390 | [switch]$IgnoreCertificateValidationErrors, 391 | [Parameter(Mandatory=$false, HelpMessage='Whether to perform a Symantec BlueCoat Site Review lookup on the URL. Warning: The BlueCoat Site Review REST API is rate limited. Automatic throttling is performed when this parameter is used.')] 392 | [switch]$PerformBluecoatLookup 393 | ) 394 | 395 | $parameters = $PSBoundParameters 396 | 397 | $isVerbose = $verbosePreference -eq 'Continue' 398 | 399 | if ($TestUrl.OriginalString.ToLower().StartsWith('http://') -or $TestUrl.OriginalString.ToLower().StartsWith('https://')) { 400 | $testUri = $TestUrl 401 | } else { 402 | $testUri = [Uri]('http://{0}' -f $testUri.OriginalString) 403 | } 404 | 405 | if($parameters.ContainsKey('UrlPattern')) { 406 | $UnblockUrl = $UrlPattern 407 | } else { 408 | $UnblockUrl = $testUri.OriginalString # ('{0}//{1}' -f $testUri.Scheme,$testUri.Host) 409 | } 410 | 411 | $newLine = [System.Environment]::NewLine 412 | 413 | Write-Verbose -Message ('{0}*************************************************{1}Testing {2}{3}*************************************************{4}' -f $newLine,$newLine,$testUri,$newLine,$newLine) 414 | 415 | $script:ServerCertificate = $null 416 | $script:ServerCertificateChain = $null 417 | $script:ServerCertificateError = $null 418 | 419 | # can't use Invoke-WebRequest and override the callback due to PowerShell Runspace errors described in this post: http://huddledmasses.org/blog/validating-self-signed-certificates-properly-from-powershell/ 420 | 421 | if($IgnoreCertificateValidationErrors) { 422 | $RemoteCertificateValidationCallback = { 423 | param([object]$sender, [Security.Cryptography.X509Certificates.X509Certificate]$certificate, [Security.Cryptography.X509Certificates.X509Chain]$chain, [Net.Security.SslPolicyErrors]$sslPolicyErrors) 424 | 425 | $script:ServerCertificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $certificate 426 | $script:ServerCertificateChain = $chain | Select-Object * # clone chain object otherwise we lose ChainElements and ChainStatus property contents on variable assignment... weird 427 | $script:ServerCertificateError = $sslPolicyErrors 428 | return $true 429 | } 430 | } else { 431 | $RemoteCertificateValidationCallback = { 432 | param([object]$sender, [Security.Cryptography.X509Certificates.X509Certificate]$certificate, [Security.Cryptography.X509Certificates.X509Chain]$chain, [Net.Security.SslPolicyErrors]$sslPolicyErrors) 433 | 434 | $script:ServerCertificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $certificate 435 | $script:ServerCertificateChain = $chain | Select-Object * # clone chain object otherwise we lose ChainElements and ChainStatus property contents on variable assignment... weird 436 | $script:ServerCertificateError = $sslPolicyErrors 437 | 438 | return [Net.Security.SslPolicyErrors]::None -eq $sslPolicyErrors 439 | } 440 | } 441 | 442 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls11 443 | 444 | $proxyUri = [Net.WebRequest]::GetSystemWebProxy().GetProxy($testUri) 445 | 446 | $request = [Net.WebRequest]::CreateHttp($testUri) 447 | $request.Proxy = if ($testUri -ne $proxyUri) { [Net.WebRequest]::DefaultWebProxy } else { $null } 448 | $request.UseDefaultCredentials = ($testUri -ne $proxyUri) 449 | $request.UserAgent = $UserAgent; 450 | $request.Method = $Method 451 | $request.ServerCertificateValidationCallback = $RemoteCertificateValidationCallback 452 | 453 | $statusCode = 0 454 | $statusMessage = '' 455 | $response = $null 456 | 457 | try { 458 | $response = $request.GetResponse() 459 | $httpResponse = $response -as [Net.HttpWebResponse] 460 | 461 | $statusCode = $httpResponse.StatusCode 462 | $statusMessage = $httpResponse.StatusDescription 463 | } catch [System.Net.WebException] { 464 | # useful WINHTTP error message code values and descriptions. will be in the exception 465 | # https://msdn.microsoft.com/en-us/library/windows/desktop/aa383770(v=vs.85).aspx 466 | # https://msdn.microsoft.com/en-us/library/windows/desktop/aa384110(v=vs.85).aspx 467 | 468 | $statusMessage = Get-ErrorMessage -ErrorRecord $_ 469 | 470 | try { 471 | $statusCode = [int]$_.Exception.Response.StatusCode # StatusCode property results in a PropertyNotFoundException exception when the URL is blocked upstream 472 | } catch [System.Management.Automation.PropertyNotFoundException] { 473 | Write-Verbose -Message ('Unable to access {0} due to {1}' -f $testUri,$statusMessage) 474 | } 475 | } finally { 476 | if ($null -ne $response) { 477 | $response.Close() 478 | } 479 | } 480 | 481 | 482 | $hasServerCertificateError = if ($null -eq $script:ServerCertificateError -or $IgnoreCertificateValidationErrors) { $false } else { $script:ServerCertificateError -ne [Net.Security.SslPolicyErrors]::None } 483 | 484 | $serverCertificateErrorMessage = '' 485 | 486 | if ($testUri.Scheme.ToLower() -eq 'https' -and $hasServerCertificateError) { 487 | $serverCertificateErrorMessage = Get-CertificateErrorMessage -Url $testUri -Certificate $script:ServerCertificate -Chain $script:ServerCertificateChain -PolicyError $script:ServerCertificateError 488 | } 489 | 490 | $serverCertificateObject = [pscustomobject]@{ 491 | Certificate = $script:ServerCertificate | Select-Object -Property * -ExcludeProperty RawData; # RawData property makes JSON files to large when calling Save-HttpConnectivity 492 | Chain = $script:ServerCertificateChain; 493 | Error = $script:ServerCertificateError; 494 | ErrorMessage = $serverCertificateErrorMessage; 495 | HasError = $hasServerCertificateError; 496 | IgnoreError = $IgnoreCertificateValidationErrors; 497 | } 498 | 499 | $address = Get-IPAddress -Url $testUri -Verbose:$false 500 | $alias = Get-IPAlias -Url $testUri -Verbose:$false 501 | $resolved = (@($address)).Length -ge 1 -or (@($alias)).Length -ge 1 502 | $actualStatusCode = [int]$statusCode 503 | $isBlocked = $statusCode -eq 0 -and $resolved 504 | $urlType = if ($UnblockUrl.Contains('*')) { 'Pattern' } else { 'Literal' } 505 | 506 | $isUnexpectedStatus = !($statusCode -in @(200,400,403,404,500,501,503,504)) 507 | $simpleStatusMessage = if ($isUnexpectedStatus) { $statusMessage } else { '' } 508 | 509 | $connectivitySummary = ('{0}Test Url: {1}{2}Url to Unblock: {3}{4}Url Type: {5}{6}Description: {7}{8}Resolved: {9}{10}IP Addresses: {11}{12}DNS Aliases: {13}{14}Actual Status Code: {15}{16}Expected Status Code: {17}{18}Is Unexpected Status Code: {19}{20}Status Message: {21}{22}Blocked: {23}{24}Certificate Error: {25}{26}Certificate Error Message: {27}{28}Ignore Certificate Validation Errors: {29}{30}{31}' -f $newLine,$testUri,$newLine,$UnblockUrl,$newLine,$urlType,$newLine,$Description,$newLine,$resolved,$newLine,($address -join ', '),$newLine,($alias -join ', '),$newLine,$actualStatusCode,$newLine,($ExpectedStatusCode -join ","),$newLine,$isUnexpectedStatus,$newLine,$simpleStatusMessage,$newLine,$isBlocked,$newLine,$serverCertificateObject.HasError,$newLine,$serverCertificateObject.ErrorMessage,$newLine,$serverCertificateObject.IgnoreError,$newLine,$newLine) 510 | Write-Verbose -Message $connectivitySummary 511 | 512 | $bluecoat = $null 513 | 514 | if ($PerformBluecoatLookup) { 515 | try { 516 | $bluecoat = Get-BlueCoatSiteReview -Url $testUri -Verbose:$isVerbose 517 | } catch { 518 | Write-Verbose -Message $_ 519 | } 520 | } 521 | 522 | $connectivity = [pscustomobject]@{ 523 | TestUrl = $testUri; 524 | UnblockUrl = $UnblockUrl; 525 | UrlType = $urlType; 526 | Resolved = $resolved; 527 | IpAddresses = [string[]]$address; 528 | DnsAliases = [string[]]$alias; 529 | Description = $Description; 530 | ActualStatusCode = [int]$actualStatusCode; 531 | ExpectedStatusCode = [Int32[]]$ExpectedStatusCode; 532 | UnexpectedStatus = $isUnexpectedStatus; 533 | StatusMessage = $simpleStatusMessage; 534 | DetailedStatusMessage = $statusMessage; 535 | Blocked = $isBlocked; 536 | ServerCertificate = $serverCertificateObject; 537 | BlueCoat = $bluecoat; 538 | } 539 | 540 | return $connectivity 541 | } 542 | 543 | Function Save-HttpConnectivity() { 544 | <# 545 | .SYNOPSIS 546 | Saves HTTP connectivity objects to a JSON file. 547 | 548 | .DESCRIPTION 549 | Saves HTTP connectivity objects to a JSON file. 550 | 551 | .EXAMPLE 552 | Save-HttpConnectivity -FileName 'Connectivity' -Objects $connectivity 553 | 554 | .EXAMPLE 555 | Save-HttpConnectivity -FileName 'Connectivity' -Objects $connectivity -OutputPath "$env:userprofile\Documents\ConnectivityTestResults" 556 | 557 | .EXAMPLE 558 | Save-HttpConnectivity -FileName 'Connectivity' -Objects $connectivity -Compress 559 | #> 560 | [CmdletBinding()] 561 | [OutputType([void])] 562 | Param( 563 | [Parameter(Mandatory=$true, HelpMessage='The filename without the extension.')] 564 | [ValidateNotNullOrEmpty()] 565 | [string]$FileName, 566 | 567 | [Parameter(Mandatory=$true, HelpMessage='The connectivity object(s) to save.')] 568 | [System.Collections.Generic.List[pscustomobject]]$Objects, 569 | 570 | [Parameter(Mandatory=$false, HelpMessage="The path to save the file to. Defaults to the user's Desktop folder.")] 571 | [string]$OutputPath, 572 | 573 | [Parameter(Mandatory=$false, HelpMessage='Compress the JSON text output.')] 574 | [switch]$Compress 575 | ) 576 | 577 | $parameters = $PSBoundParameters 578 | 579 | if (-not($parameters.ContainsKey('OutputPath'))) { 580 | $OutputPath = $env:USERPROFILE,'Desktop' -join [System.IO.Path]::DirectorySeparatorChar 581 | } 582 | 583 | $OutputPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputPath) 584 | 585 | if (-not(Test-Path -Path $OutputPath)) { 586 | New-Item -Path $OutputPath -ItemType Directory 587 | } 588 | 589 | #$fileName = ($targetUrl.OriginalString.Split([string[]][IO.Path]::GetInvalidFileNameChars(),[StringSplitOptions]::RemoveEmptyEntries)) -join '-' 590 | $json = $Objects | ConvertTo-Json -Depth 3 -Compress:$Compress 591 | $json | Out-File -FilePath "$OutputPath\$FileName.json" -NoNewline -Force 592 | } 593 | -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/NestedModules/TcpConnectivityTester/TcpConnectivityTester.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThomasKur/ModernWorkplaceClientCenter/05eb15ee9c2168ebf935a6521688268983506f00/PSModule/ModernWorkplaceClientCenter/NestedModules/TcpConnectivityTester/TcpConnectivityTester.psd1 -------------------------------------------------------------------------------- /PSModule/ModernWorkplaceClientCenter/NestedModules/TcpConnectivityTester/TcpConnectivityTester.psm1: -------------------------------------------------------------------------------- 1 | Set-StrictMode -Version 4 2 | 3 | Function Get-ErrorMessage() { 4 | <# 5 | .SYNOPSIS 6 | Gets a formatted error message from an error record. 7 | 8 | .DESCRIPTION 9 | Gets a formatted error message from an error record. 10 | 11 | .EXAMPLE 12 | Get-ErrorMessage -ErrorRecords $_ 13 | #> 14 | [CmdletBinding()] 15 | [OutputType([string])] 16 | Param( 17 | [Parameter(Mandatory=$true, HelpMessage='The PowerShell error record object to get information from')] 18 | [ValidateNotNullOrEmpty()] 19 | [System.Management.Automation.ErrorRecord]$ErrorRecord 20 | ) 21 | Process { 22 | $msg = [System.Environment]::NewLine,'Exception Message: ',$ErrorRecord.Exception.Message -join '' 23 | 24 | if($null -ne $ErrorRecord.Exception.HResult) { 25 | $msg = $msg,[System.Environment]::NewLine,'Exception HRESULT: ',('{0:X}' -f $ErrorRecord.Exception.HResult),$ErrorRecord.Exception.HResult -join '' 26 | } 27 | 28 | if($null -ne $ErrorRecord.Exception.StackTrace) { 29 | $msg = $msg,[System.Environment]::NewLine,'Exception Stacktrace: ',$ErrorRecord.Exception.StackTrace -join '' 30 | } 31 | 32 | if ($null -ne ($ErrorRecord.Exception | Get-Member | Where-Object { $_.Name -eq 'WasThrownFromThrowStatement'})) { 33 | $msg = $msg,[System.Environment]::NewLine,'Explicitly Thrown: ',$ErrorRecord.Exception.WasThrownFromThrowStatement -join '' 34 | } 35 | 36 | if ($null -ne $ErrorRecord.Exception.InnerException) { 37 | if ($ErrorRecord.Exception.InnerException.Message -ne $ErrorRecord.Exception.Message) { 38 | $msg = $msg,[System.Environment]::NewLine,'Inner Exception: ',$ErrorRecord.Exception.InnerException.Message -join '' 39 | } 40 | 41 | if($null -ne $ErrorRecord.Exception.InnerException.HResult) { 42 | $msg = $msg,[System.Environment]::NewLine,'Inner Exception HRESULT: ',('{0:X}' -f $ErrorRecord.Exception.InnerException.HResult),$ErrorRecord.Exception.InnerException.HResult -join '' 43 | } 44 | } 45 | 46 | $msg = $msg,[System.Environment]::NewLine,'Call Site: ',$ErrorRecord.InvocationInfo.PositionMessage -join '' 47 | 48 | if ($null -ne ($ErrorRecord | Get-Member | Where-Object { $_.Name -eq 'ScriptStackTrace'})) { 49 | $msg = $msg,[System.Environment]::NewLine,"Script Stacktrace: ",$ErrorRecord.ScriptStackTrace -join '' 50 | } 51 | 52 | return $msg 53 | } 54 | } 55 | 56 | 57 | 58 | Function Get-IPAddress() { 59 | <# 60 | .SYNOPSIS 61 | Gets the IP address(es) for a hostname. 62 | 63 | .DESCRIPTION 64 | Gets the IP address(es) for a hostname. 65 | 66 | .EXAMPLE 67 | Get-IPAddress -Hostname www.site.com 68 | #> 69 | [CmdletBinding()] 70 | [OutputType([string[]])] 71 | Param ( 72 | [Parameter(Mandatory=$true, HelpMessage='The Hostname to get the IP address for.')] 73 | [ValidateNotNullOrEmpty()] 74 | [Alias("Url")] 75 | [String]$Hostname 76 | ) 77 | 78 | $addresses = [string[]]@() 79 | 80 | $dnsResults = $null 81 | 82 | $dnsResults = @(Resolve-DnsName -Name $Hostname -NoHostsFile -Type A_AAAA -QuickTimeout -ErrorAction SilentlyContinue | Where-Object {$_.Type -eq 'A'}) 83 | 84 | $addresses = [string[]]@($dnsResults | ForEach-Object { try { $_.IpAddress } catch [System.Management.Automation.PropertyNotFoundException] {Write-Verbose "No IP in Object."} }) # IpAddress results in a PropertyNotFoundException when a URL is blocked upstream 85 | 86 | return [string[]](,$addresses) 87 | } 88 | 89 | Function Get-IPAlias() { 90 | <# 91 | .SYNOPSIS 92 | Gets DNS alias for a Hostname. 93 | 94 | .DESCRIPTION 95 | Gets DNS alias for a Hostname. 96 | 97 | .EXAMPLE 98 | Get-IPAlias -Hostname http://www.site.com 99 | #> 100 | [CmdletBinding()] 101 | [OutputType([string[]])] 102 | Param ( 103 | [Parameter(Mandatory=$true, HelpMessage='The Hostname to get the alias address for.')] 104 | [ValidateNotNullOrEmpty()] 105 | [Alias("Url")] 106 | [String]$Hostname 107 | ) 108 | 109 | $aliases = [string[]]@() 110 | 111 | $dnsResults = $null 112 | 113 | $dnsResults = @(Resolve-DnsName -Name $Hostname -NoHostsFile -QuickTimeout -ErrorAction SilentlyContinue | Where-Object { $_.Type -eq 'CNAME' }) 114 | 115 | $aliases = [string[]]@($dnsResults | ForEach-Object { $_.NameHost }) 116 | 117 | return [string[]](,$aliases) 118 | } 119 | 120 | 121 | 122 | Function Get-TcpConnectivity() { 123 | <# 124 | .SYNOPSIS 125 | Gets TCP connectivity information for a hostname and port. 126 | 127 | .DESCRIPTION 128 | Gets TCP connectivity information for a hostname and port. 129 | 130 | .EXAMPLE 131 | Get-TcpConnectivity -TestHostname "www.site.com" -TestPort 111 132 | 133 | .EXAMPLE 134 | Get-TcpConnectivity -TestHostname "www.site.com" -TestPort 111 -HostnamePattern "*.site.com" -Description 'A site that does something' 135 | 136 | #> 137 | [CmdletBinding()] 138 | [OutputType([void])] 139 | Param( 140 | [Parameter(Mandatory=$true, HelpMessage='The hostname to test.')] 141 | [ValidateNotNullOrEmpty()] 142 | [String]$TestHostname, 143 | 144 | [Parameter(Mandatory=$true, HelpMessage='The TCP port to test.')] 145 | [ValidateNotNullOrEmpty()] 146 | [Int32]$TestPort, 147 | 148 | [Parameter(Mandatory=$true, HelpMessage='The Expected status code.')] 149 | [Int32]$ExpectedStatusCode, 150 | 151 | [Parameter(Mandatory=$false, HelpMessage='The hostname pattern to unblock when the hostname to unblock is not a literal hostname.')] 152 | [ValidateNotNullOrEmpty()] 153 | [string]$HostnamePattern, 154 | 155 | [Parameter(Mandatory=$false, HelpMessage='A description of the connectivity test or purpose of the hostname.')] 156 | [ValidateNotNullOrEmpty()] 157 | [string]$Description 158 | 159 | ) 160 | 161 | $parameters = $PSBoundParameters 162 | 163 | $isVerbose = $verbosePreference -eq 'Continue' 164 | 165 | $TestHostname = $TestHostname.ToLower() 166 | 167 | 168 | if($parameters.ContainsKey('HostnamePattern')) { 169 | $UnblockHostname = $HostnamePattern 170 | } else { 171 | $UnblockHostname = $TestHostname 172 | } 173 | 174 | $newLine = [System.Environment]::NewLine 175 | 176 | Write-Verbose -Message ('{0}*************************************************{1}Testing {2}{3}*************************************************{4}' -f $newLine,$newLine,$TestHostname,$newLine,$newLine) 177 | 178 | 179 | $statusCode = 0 180 | $statusMessage = '' 181 | $response = $null 182 | 183 | try { 184 | $response = Test-NetConnection -ComputerName $TestHostname -Port $TestPort -Verbose:$isVerbose 185 | if($response.TcpTestSucceeded){ 186 | $statusCode = 1 187 | $statusMessage = "Tcp test succeeded" 188 | } elseif($response.PingSucceeded){ 189 | $statusCode = 2 190 | $statusMessage = "Ping test succeeded" 191 | } elseif($response.NameResolutionSucceeded){ 192 | $statusCode = 3 193 | $statusMessage = "Name resolution succeeded" 194 | }else { 195 | $statusCode = 5 196 | $statusMessage = "Unknown error" 197 | } 198 | 199 | 200 | } catch { 201 | $statusMessage = Get-ErrorMessage -ErrorRecord $_ 202 | } 203 | 204 | $address = Get-IPAddress -Hostname $TestHostname -Verbose:$false 205 | $alias = Get-IPAlias -Hostname $TestHostname -Verbose:$false 206 | $resolved = (@($address)).Length -ge 1 -or (@($alias)).Length -ge 1 207 | $actualStatusCode = [int]$statusCode 208 | $isBlocked = $statusCode -eq 1 -and $resolved 209 | $urlType = if ($HostnamePattern.Contains('*')) { 'Pattern' } else { 'Literal' } 210 | 211 | $isUnexpectedStatus = $statusCode -ne 1 212 | $simpleStatusMessage = if ($isUnexpectedStatus) { $statusMessage } else { '' } 213 | 214 | $connectivitySummary = ('{0}Test Hostname: {1}{2}Hostname to Unblock: {3}{4}Hostname Type: {5}{6}Description: {7}{8}Resolved: {9}{10}IP Addresses: {11}{12}DNS Aliases: {13}{14}Actual Status Code: {15}{16}Expected Status Code: {17}{18}Is Unexpected Status Code: {19}{20}Status Message: {21}{22}Blocked: {23}{24}{25}' -f $newLine,$TestHostname,$newLine,$HostnamePattern,$newLine,$urlType,$newLine,$Description,$newLine,$resolved,$newLine,($address -join ', '),$newLine,($alias -join ', '),$newLine,$actualStatusCode,$newLine,$ExpectedStatusCode,$newLine,$isUnexpectedStatus,$newLine,$simpleStatusMessage,$newLine,$isBlocked,$newLine,$newLine) 215 | Write-Verbose -Message $connectivitySummary 216 | 217 | $connectivity = [pscustomobject]@{ 218 | TestUrl = $TestHostname; 219 | UnblockUrl = $UnblockHostname; 220 | UrlType = $urlType; 221 | Resolved = $resolved; 222 | IpAddresses = [string[]]$address; 223 | DnsAliases = [string[]]$alias; 224 | Description = $Description; 225 | ActualStatusCode = [int]$actualStatusCode; 226 | ExpectedStatusCode = $ExpectedStatusCode; 227 | UnexpectedStatus = $isUnexpectedStatus; 228 | StatusMessage = $simpleStatusMessage; 229 | DetailedStatusMessage = $statusMessage; 230 | Blocked = $isBlocked; 231 | ServerCertificate = $null; 232 | } 233 | 234 | return $connectivity 235 | } 236 | 237 | Function Save-TcpConnectivity() { 238 | <# 239 | .SYNOPSIS 240 | Saves TCP connectivity objects to a JSON file. 241 | 242 | .DESCRIPTION 243 | Saves TCP connectivity objects to a JSON file. 244 | 245 | .EXAMPLE 246 | Save-TcpConnectivity -FileName 'Connectivity' -Objects $connectivity 247 | 248 | .EXAMPLE 249 | Save-TcpConnectivity -FileName 'Connectivity' -Objects $connectivity -OutputPath "$env:userprofile\Documents\ConnectivityTestResults" 250 | 251 | .EXAMPLE 252 | Save-TcpConnectivity -FileName 'Connectivity' -Objects $connectivity -Compress 253 | #> 254 | [CmdletBinding()] 255 | [OutputType([void])] 256 | Param( 257 | [Parameter(Mandatory=$true, HelpMessage='The filename without the extension.')] 258 | [ValidateNotNullOrEmpty()] 259 | [string]$FileName, 260 | 261 | [Parameter(Mandatory=$true, HelpMessage='The connectivity object(s) to save.')] 262 | [System.Collections.Generic.List[pscustomobject]]$Objects, 263 | 264 | [Parameter(Mandatory=$false, HelpMessage="The path to save the file to. Defaults to the user's Desktop folder.")] 265 | [string]$OutputPath, 266 | 267 | [Parameter(Mandatory=$false, HelpMessage='Compress the JSON text output.')] 268 | [switch]$Compress 269 | ) 270 | 271 | $parameters = $PSBoundParameters 272 | 273 | if (-not($parameters.ContainsKey('OutputPath'))) { 274 | $OutputPath = $env:USERPROFILE,'Desktop' -join [System.IO.Path]::DirectorySeparatorChar 275 | } 276 | 277 | $OutputPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputPath) 278 | 279 | if (-not(Test-Path -Path $OutputPath)) { 280 | New-Item -Path $OutputPath -ItemType Directory 281 | } 282 | 283 | $json = $Objects | ConvertTo-Json -Depth 3 -Compress:$Compress 284 | $json | Out-File -FilePath "$OutputPath\$FileName.json" -NoNewline -Force 285 | } 286 | -------------------------------------------------------------------------------- /PSModule/build.ps1: -------------------------------------------------------------------------------- 1 | $ModulePath = ".\PSModule\ModernWorkplaceClientCenter" 2 | 3 | #region UI 4 | $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Description." 5 | $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Description." 6 | $cancel = New-Object System.Management.Automation.Host.ChoiceDescription "&Cancel","Description." 7 | $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no, $cancel) 8 | 9 | $title = "Version History" 10 | $message = "Have you updated the Release Notes for the new Version?" 11 | $result = $host.ui.PromptForChoice($title, $message, $options, 1) 12 | switch ($result) { 13 | 0{ 14 | 15 | } 16 | 1{ 17 | Write-Error "Canceled Publishing Process" -ErrorAction Stop 18 | } 19 | 2{ 20 | Write-Error "Canceled Publishing Process" -ErrorAction Stop 21 | } 22 | } 23 | #endregion 24 | 25 | #region Code Analyzer 26 | Import-Module -Name PSScriptAnalyzer -Force 27 | $ScriptAnalyzerResult = Invoke-ScriptAnalyzer -Path $ModulePath -Recurse -ErrorAction Stop -ExcludeRule @("PSAvoidTrailingWhitespace") 28 | 29 | if($ScriptAnalyzerResult){ 30 | $ScriptAnalyzerResult 31 | Write-Error "Scripts contains errors. PSScriptAnalyzer provided results above." 32 | } 33 | #endregion 34 | 35 | #region Build Manifest 36 | $ExportableFunctions = (Get-ChildItem -Path "$ModulePath\Functions" -Filter '*.ps1').BaseName 37 | $ReleaseNotes = ((Get-Content ".\ReleaseNotes.md" -Raw) -split "##") 38 | $ReleaseNote = ($ReleaseNotes[1] + "`n`n To see the complete history, checkout the Release Notes on Github") 39 | 40 | #Update Version 41 | $ModuelManifestTest = Test-ModuleManifest -Path "$ModulePath\ModernWorkplaceClientCenter.psd1" -ErrorAction Stop 42 | $CurrentVersion = $ModuelManifestTest.Version 43 | $SuggestedNewVersion = [Version]::new($CurrentVersion.Major,$CurrentVersion.Minor,$CurrentVersion.Build + 1) 44 | $title = "Increment Version" 45 | $message = "Would you like to increase Module Version from $($CurrentVersion) to $($SuggestedNewVersion)?" 46 | $result = $host.ui.PromptForChoice($title, $message, $options, 1) 47 | switch ($result) { 48 | 0{ 49 | Write-Information "You selected yes to increase the version. Updating Mnaifest..." 50 | Update-ModuleManifest -Path "$ModulePath\ModernWorkplaceClientCenter.psd1" ` 51 | -FunctionsToExport $ExportableFunctions ` 52 | -ReleaseNotes $ReleaseNote ` 53 | -NestedModules @("NestedModules/HttpConnectivityTester/HttpConnectivityTester.psm1","NestedModules/TcpConnectivityTester/TcpConnectivityTester.psm1") ` 54 | -IconUri "https://raw.githubusercontent.com/ThomasKur/ModernWorkplaceClientCenter/master/Logo/MWCC-Logo-512.png" ` 55 | -ModuleVersion $SuggestedNewVersion 56 | } 57 | 1{ 58 | Write-Host "You selected no. The version will not be increased." 59 | Update-ModuleManifest -Path "$ModulePath\ModernWorkplaceClientCenter.psd1" ` 60 | -FunctionsToExport $ExportableFunctions ` 61 | -ReleaseNotes $ReleaseNote ` 62 | -NestedModules @("NestedModules/HttpConnectivityTester/HttpConnectivityTester.psm1","NestedModules/TcpConnectivityTester/TcpConnectivityTester.psm1") ` 63 | -IconUri "https://raw.githubusercontent.com/ThomasKur/ModernWorkplaceClientCenter/master/Logo/MWCC-Logo-512.png" ` 64 | -ModuleVersion $CurrentVersion 65 | } 66 | 2{ 67 | Write-Error "Canceled Publishing Process" -ErrorAction Stop 68 | } 69 | } 70 | Test-ModuleManifest -Path "$ModulePath\ModernWorkplaceClientCenter.psd1" -ErrorAction Stop 71 | #endregion 72 | 73 | #region Sign Scripts 74 | Copy-Item -Path $ModulePath -Destination $env:TEMP -Recurse -Force 75 | $cert = get-item Cert:\CurrentUser\My\* -CodeSigningCert | Out-GridView -OutputMode Single 76 | $PSFiles = Get-ChildItem -Path $env:TEMP\ModernWorkplaceClientCenter -Recurse | Where-Object {$_.Extension -eq ".ps1" -or $_.Extension -eq ".psm1"} 77 | foreach($PSFile in $PSFiles){ 78 | Set-AuthenticodeSignature -Certificate $cert -TimestampServer http://timestamp.verisign.com/scripts/timstamp.dll -FilePath ($PSFile.FullName) -Verbose 79 | } 80 | #endregion 81 | $PSGallerAPIKey = Read-Host "Insert PSGallery API Key" 82 | Publish-Module -Path $env:TEMP\ModernWorkplaceClientCenter -NuGetApiKey $PSGallerAPIKey -Verbose 83 | -------------------------------------------------------------------------------- /PSModule/cacheHttpResults.ps1: -------------------------------------------------------------------------------- 1 | $ModulePath = "$PSScriptRoot\ModernWorkplaceClientCenter" 2 | . "$PSScriptRoot\ModernWorkplaceClientCenter\Internal\Get-UrlWildCardLookup.ps1" 3 | $HttpConModulePath = "$PSScriptRoot\ModernWorkplaceClientCenter\NestedModules\HttpConnectivityTester\HttpConnectivityTester.psd1" 4 | Import-Module $HttpConModulePath 5 | $TcpConModulePath = "$PSScriptRoot\ModernWorkplaceClientCenter\NestedModules\TcpConnectivityTester\TcpConnectivityTester.psd1" 6 | Import-Module $TcpConModulePath 7 | #region Update Azure Endpoints 8 | $Endpoints = Invoke-WebRequest -Uri "https://endpoints.office.com/endpoints/worldwide?clientrequestid=$(New-Guid)" 9 | Out-File -FilePath "$ModulePath\Data\AzureEndpointCache.json" -InputObject $Endpoints.content -Force 10 | #endregion Update Azure Endpoints 11 | 12 | #region Expected Results 13 | $data = New-Object System.Collections.Generic.List[PSCustomObject] 14 | $EndpointsObjs = $Endpoints.content | ConvertFrom-Json 15 | Write-Verbose "Found $($EndpointsObjs.length) endpoints to check" 16 | foreach($EndpointsObj in $EndpointsObjs){ 17 | if($null -eq $EndpointsObj.tcpPorts){ 18 | Add-Member -InputObject $EndpointsObj -MemberType NoteProperty -Name tcpPorts -Value "443" 19 | } 20 | foreach($Port in $EndpointsObj.tcpPorts.Split(',')){ 21 | switch ($Port) { 22 | 80 {$Protocol = "http://"; $UsePort = "";$TestType="HTTP"; break} 23 | 443 {$Protocol = "https://"; $UsePort = "";$TestType="HTTP"; break} 24 | default {$Protocol = ""; $UsePort = $Port;$TestType="TCP"; break} 25 | } 26 | if($EndpointsObj.PSObject.Properties.Name -match "notes"){ 27 | $Notes = " - " + $EndpointsObj.notes 28 | } else { 29 | $Notes = "" 30 | } 31 | foreach($url in $EndpointsObj.urls){ 32 | if($url -notmatch "\*"){ 33 | $data.Add([PSCustomObject]@{ TestType = $TestType; TestUrl = $url; UsePort = $UsePort; Protocol = $Protocol; UrlPattern = $url; Description = "$($EndpointsObj.serviceAreaDisplayName)$Notes"; PerformBluecoatLookup=$false; Verbose=$false }) 34 | } else { 35 | $staticUrls = Get-UrlWildCardLookup -Url $url -Path $ModulePath 36 | foreach($staticUrl in $staticUrls){ 37 | $data.Add([PSCustomObject]@{ TestType = $TestType; TestUrl = $staticUrl; UsePort = $UsePort; Protocol = $Protocol; UrlPattern = $url; Description = "$($EndpointsObj.serviceAreaDisplayName)$Notes"; PerformBluecoatLookup=$false; Verbose=$false }) 38 | } 39 | } 40 | } 41 | } 42 | } 43 | 44 | $results = New-Object System.Collections.Generic.List[pscustomobject] 45 | 46 | $i = 0 47 | <# 48 | ForEach($d in $data) { 49 | Write-Progress -Activity "Connectivity Tests" -status "Processing $($d.TestUrl)" -percentComplete ($i / $data.count*100) 50 | $connectivity = Get-HttpConnectivity -TestUrl $d.TestUrl -Method "GET" -UrlPattern $d.UrlPattern -ExpectedStatusCode $d.ExpectedStatusCode -Description $d.Description -PerformBluecoatLookup $d.PerformBluecoatLookup -IgnoreCertificateValidationErrors 51 | $results.Add($connectivity) 52 | $i += 1 53 | }#> 54 | 55 | foreach ($d in $data) { 56 | $running = @(Get-Job | Where-Object { $_.State -eq 'Running' }) 57 | if ($running.Count -ge 10) { 58 | $running | Wait-Job -Any | Out-Null 59 | } 60 | 61 | Write-Progress -Activity "Connectivity Tests" -status "Processing $($d.TestUrl)" -percentComplete ($i / $data.count*100) 62 | 63 | $i += 1 64 | Start-Job -ArgumentList @($d,$HttpConModulePath,$TcpConModulePath) -ScriptBlock { 65 | param($d,$HttpConModulePath,$TcpConModulePath) 66 | 67 | 68 | if($d.TestType -eq "HTTP"){ 69 | Import-Module $HttpConModulePath 70 | $connectivity = Get-HttpConnectivity -TestUrl ($d.Protocol + $d.TestUrl) -Method "GET" -UrlPattern ($d.Protocol + $d.UrlPattern) -ExpectedStatusCode 200 -Description $d.Description -IgnoreCertificateValidationErrors 71 | } else { 72 | Import-Module $TcpConModulePath 73 | $connectivity = Get-TcpConnectivity -TestHostname $d.TestUrl -TestPort $d.UsePort -HostnamePattern ($d.UrlPattern + ":" + $d.UsePort) -ExpectedStatusCode 1 -Description $d.Description 74 | } 75 | $connectivity 76 | } | Out-Null 77 | } 78 | 79 | # Wait for all jobs to complete and results ready to be received 80 | Wait-Job * | Out-Null 81 | 82 | # Process the results 83 | foreach($job in Get-Job) 84 | { 85 | $result = Receive-Job $job -AutoRemoveJob -Wait 86 | $results.Add($result) 87 | } 88 | 89 | $CachedResults = $results | Foreach-Object { [pscustomobject]@{ 90 | UnblockUrl = $_.UnblockUrl; 91 | ActualStatusCode = $_.ActualStatusCode; 92 | Blocked = $_.Blocked; 93 | HasError = $_.ServerCertificate.HasError; 94 | }} | Select-Object UnblockUrl,ActualStatusCode,HasError,Blocked 95 | Out-File -FilePath "$ModulePath\Data\AzureEndpointExpectedResults.json" -InputObject ($CachedResults | ConvertTo-Json) -Force 96 | #endregion Expected Results -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Modern Workplace Client Center 2 | 3 | MWCC LogoThis repository will be the home of a PowerShell Module, which helps to simplify tasks on MDM managed Windows clients. In a second step there will be a UI, which leverages these PowerShell functions for Admins which like a UI. Feedback is welcome! 4 | 5 | ## PowerShell Module 6 | 7 | This PowerShell module will contain all functions for DevOps like me, which like to use PowerShell everywhere. The goal of the module is not only to read and display properties, instead it should correleate settings and event log entries together and help you during troubleshooting. If you have some specific use cases like "If this happens, then you can apply this solution", then I'm happy to get your feedback. 8 | 9 | The following functions are available now: 10 | 11 | * Get-DsRegStatus --> Ever used dsregcmd and thought about why it is not a PowerShell command? Here it is... 12 | * Invoke-AnalyzeHybridJoinStatus --> Troubleshoots Azure Hybrid Join status and covers already 17 checks. 13 | * Invoke-AnalyzeMDMEnrollmentStatus --> Troubleshoots Windows 10 MDM Enrollment status and covers 6 checks. 14 | * Get-SiteToZoneAssignment --> Returns Internet Explorer Site to Zone assignments. This is more a helper function, but perhaps it helps you somewhere else. 15 | * Get-MdmMsiApp --> Retrieves information about all MDM assigned applications, including their installation state. 16 | * Get-MDMDeviceOwnership --> Returns information about the Ownership of the Device. 17 | * Reset-MDMEnrollmentStatus --> Resets Windows 10 MDM Enrollment Status. 18 | * Get-MDMEnrollmentStatus --> Get Windows 10 MDM Enrollment Status. 19 | * Get-MDMPSScriptStatus --> Returns information about the execution of PowerShell Scripts deployed with Intune. 20 | * Get-BCStatusDetailed --> Returns Branch Cache usage statistsics of the last downloads per source host including peer usage statistics. 21 | * Invoke-AnalyzeDeliveryOptimization --> Analyze Delivery Optimization Configuration and connectifity on a device. 22 | * Invoke-AnalyzeAzureConnectivity --> Check for connectivity issues to O365 and Azure based on the actual published list of Microsoft(https://docs.microsoft.com/en-us/office365/enterprise/urls-and-ip-address-ranges). 23 | 24 | The following functions will be available in the near future: 25 | 26 | * Autopilot Troubleshooting 27 | * Improvement Intune Enrollment Troubleshooting 28 | * Improvement Intune MSI App Installation Troubleshooting 29 | * Improvement Intune PowerShell Script Installation Troubleshooting 30 | * Pester Tests 31 | 32 | ### Usage 33 | 34 | Download the PS module from the PSGallery and Import the module: 35 | 36 | ```powershell 37 | Install-Module ModernWorkplaceClientCenter 38 | ``` 39 | 40 | Get all available Commands of the module: 41 | 42 | ```powershell 43 | Get-Command -Module ModernWorkplaceClientCenter 44 | ``` 45 | 46 | ## Client Center UI 47 | 48 | This is a planned project for the next months as soon the PowerShell functions are well working. 49 | 50 | ## Issues / Feedback 51 | 52 | For any issues or feedback related to this module, please register for GitHub, and post your inquiry to this project's issue tracker. 53 | 54 | ## Contributions 55 | 56 | * HttpConncetifityTester Module: This Work was prepared by a United States Government employee and, therefore, is excluded from copyright by Section 105 of the Copyright Act of 1976. Copyright and Related Rights in the Work worldwide are waived through the [CC0 1.0 Universal license](https://creativecommons.org/publicdomain/zero/1.0/). More great tools can be found here: https://github.com/nsacyber 57 | -------------------------------------------------------------------------------- /ReleaseNotes.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## 0.1.17 - Bugfix Get-Dsregcmd 4 | 5 | * Regex change required to return every property. 6 | 7 | ## 0.1.16 - Bugfix Get-Dsregcmd 8 | 9 | * Last section was not returned 10 | 11 | ## 0.1.15 - Improving Get-Dsregcmd parsing 12 | 13 | * The sections displayed in the dsregcmd /status output are now sub objects. Therfore also multiple work accounts are not supported. 14 | * Updating chached results for connectivity tests 15 | 16 | ## 0.1.14 - Adding Invoke-TestAutopilotNetworkEndpoints and Invoke-IntuneCleanup 17 | 18 | * Automatically clean up duplicated devices in Intune based on the device serial number. 19 | * Check Autopilot Network Endpoints 20 | 21 | ## 0.1.13 - Bugfixing Invoke-AnalyzeHybridJoinStatus 22 | 23 | * Bugfix with String Array and Split Invoke-AnalyzeHybridJoinStatus. 24 | 25 | ## 0.1.12 - Improvement Invoke-AnalyzeHybridJoinStatus 26 | 27 | * Improve SCP check inInvoke-AnalyzeHybridJoinStatus to read information from root domain. 28 | 29 | ## 0.1.11 - Bugfix 30 | 31 | * Bugfix Invoke-AnalyzeAzureConnectivity 32 | 33 | ## 0.1.10 - Extended Azure AD Hybrid Join checks 34 | 35 | * Extended Azure AD Hybrid Join checks to include User Device Registration Event Log Invoke-AnalyzeHybridJoinStatus 36 | * Check manually defined IE Intranet Sites Invoke-AnalyzeHybridJoinStatus 37 | * Added TcpConnectivityTester Module to check Non HTTP Connections 38 | * Added Invoke-AnalyzeAzureConnectivity to check for connectivity issues to O365 and Azure based on the actual published list of Microsoft. 39 | 40 | ## 0.1.9 - Delivery Optimization 41 | 42 | * Improved loading of HttpConnectivtyTester Module 43 | * Added new function top analyze Delivery Optimization Configuration and connectifity on a device Invoke-AnalyzeDeliveryOptimization 44 | 45 | ## 0.1.8 - IE Site to Zone Checks improved to detect URL's correctly when entered without https 46 | 47 | * Verifiy Site to Zone alignment if not exaxtly the correct urls are entered(With or Without HTTP(S)) Invoke-AnalyzeHybridJoinStatus 48 | * Improve remediation action description if HTTP Error 407 is returned by a proxy 49 | * Added new function to analyze BranchCache traffic. Get-BCStatusDetailed 50 | 51 | ## 0.1.7 - Bugfix in Get-SiteToZoneAssignment 52 | 53 | * Bugfix Get-SiteToZoneAssignment: Method invocation failed because Microsoft.Win32.RegistryKey does not contain a method named 'op_Addition' 54 | 55 | ## 0.1.6 - Bugfix in Module Manifest 56 | 57 | * Bugfix Module manifest to Load Nested Module 58 | 59 | ## 0.1.5 - Added Connectifity Tests 60 | 61 | * Correct Typos 62 | * Added connectifity Tests to Invoke-AnalyzeHybridJoinStatus 63 | * Added Nested Module HttpConnectivityTester from https://github.com/nsacyber/HTTP-Connectivity-Tester 64 | 65 | ## 0.1.4 - Added Analytic checks 66 | 67 | * New DNS checks in Invoke-AnalyzeMDMEnrollmentStatus 68 | * Bugfix in generating Successmessage in Invoke-AnalyzeMDMEnrollmentStatus 69 | 70 | ## 0.1.3 - Improved Analytic results 71 | 72 | * Improved Anayltic results by hiding unhelpful tips when the root cause is also well known like the device is not domain joined. 73 | * Get-MDMDeviceOwnership --> Return well interpretable strings instead of just integer values. 74 | 75 | ## 0.1.2 - Bugfixing 76 | 77 | * Bugfixing Get-MDMEnrollmentStatus, Get-MDMMsiApp, Get-MDMPSScriptStatus for unenrolled devices. 78 | 79 | ## 0.1.1 - Improved build process 80 | 81 | * Improved build.ps1 82 | 83 | ## 0.1.0 - First Release 84 | 85 | * Get-DsRegStatus --> Ever used dsregcmd and thought about why it is not a PowerShell command? Here it is... 86 | * Invoke-AnalyzeHybridJoinStatus --> Troubleshoots Azure Hybrid Join status and covers already 13 checks. 87 | * Invoke-AnalyzeMDMEnrollmentStatus --> Troubleshoots Windows 10 MDM Enrollment status and covers 4 checks. 88 | * Get-SiteToZoneAssignment --> Returns Internet Explorer Site to Zone assignments. This is more a helper function, but perhaps it helps you somewhere else. 89 | * Get-MdmMsiApp --> Retrieves information about all MDM assigned applications, including their installation state. 90 | * Get-MDMDeviceOwnership --> Returns information about the Ownership of the Device. 91 | * Reset-MDMEnrollmentStatus --> Resets Windows 10 MDM Enrollment Status. 92 | * Get-MDMEnrollmentStatus --> Get Windows 10 MDM Enrollment Status. 93 | * Get-MDMPSScriptStatus --> Returns information about the execution of PowerShell Scripts deployed with Intune. 94 | --------------------------------------------------------------------------------