Home
%3CLINGO-SUB%20id%3D%22lingo-sub-914386%22%20slang%3D%22en-US%22%3ERemotely%20capture%20ConfigMgr%20client%20logs%20for%20Troubleshooting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-914386%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20is%20a%20short%20blog%20post%20about%20remotely%20capturing%20ConfigMgr%20client%20log%20files%20to%20a%20file%20share%20for%20troubleshooting%20purposes.%3C%2FP%3E%0A%3CP%3EWith%20the%20ever-increasing%20security%2C%20not%20all%20teams%20supporting%20endpoints%20necessarily%20have%20Admin%20access%20for%20troubleshooting.%20Part%20of%20which%20includes%20analyzing%20logs.%3C%2FP%3E%0A%3CP%3EYou%20may%20experience%20scenario%20where%20the%20device%20is%20not%20even%20on%20corporate%20network%20and%20you%20need%20to%20capture%20logs.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1846031829%22%20id%3D%22toc-hId-1846031829%22%3ESolution%3C%2FH2%3E%0A%3CP%3EWe%20can%20use%20the%20power%20of%20%3CSTRONG%3ERun%20Scripts%3C%2FSTRONG%3E%20feature%20to%20capture%20logs%20remotely%20against%20a%20single%20machine%20or%20a%20collection%20of%20devices%20and%20dump%20it%20against%20a%20file%20share%20for%20analysis.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--706125132%22%20id%3D%22toc-hId--706125132%22%3E%3CEM%3EPrerequisites%3C%2FEM%3E%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3E%3CEM%3ETo%20run%20PowerShell%20scripts%2C%20the%20client%20must%20be%20running%20PowerShell%20version%203.0%20or%20later.%20However%2C%20if%20a%20script%20you%20run%20contains%20functionality%20from%20a%20later%20version%20of%20PowerShell%2C%20the%20client%20on%20which%20you%20run%20the%20script%20must%20be%20running%20that%20version%20of%20PowerShell.%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3EConfiguration%20Manager%20clients%20must%20be%20running%20the%20client%20from%20the%201706%20release%2C%20or%20later%20in%20order%20to%20run%20scripts.%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3ETo%20use%20scripts%2C%20you%20must%20be%20a%20member%20of%20the%20appropriate%20Configuration%20Manager%20security%20role.%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3ETo%20import%20and%20author%20scripts%20-%20Your%20account%20must%20have%20%3CSTRONG%3ECreate%3C%2FSTRONG%3E%20permissions%20for%20%3CSTRONG%3ESMS%20Scripts%3C%2FSTRONG%3E.%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3ETo%20approve%20or%20deny%20scripts%20-%20Your%20account%20must%20have%20%3CSTRONG%3EApprove%3C%2FSTRONG%3E%20permissions%20for%20%3CSTRONG%3ESMS%20Scripts%3C%2FSTRONG%3E.%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3ETo%20run%20scripts%20-%20Your%20account%20must%20have%20%3CSTRONG%3ERun%20Script%3C%2FSTRONG%3E%20permissions%20for%20%3CSTRONG%3ECollections%3C%2FSTRONG%3E.%3C%2FEM%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CEM%3EReference%3A%20%3C%2FEM%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsccm%2Fapps%2Fdeploy-use%2Fcreate-deploy-scripts%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsccm%2Fapps%2Fdeploy-use%2Fcreate-deploy-scripts%3C%2FEM%3E%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%E2%80%99s%20the%20sample%20script%20I%20have%20use%20for%20this%20purpose%3A%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Specify%20destination%20share%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%24dest%20%3D%20%22%5C%5C%3CSERVER%3E%5CShare%22%3C%2FSERVER%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Specify%20the%20ConfigMgr%20log%20file%20location%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%24source%20%3D%20%22c%3A%5Cwindows%5Cccm%5Clogs%22%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Capturing%20Machine%20Name%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%24hostname%20%3D%20hostname%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Capturing%20current%20date%20and%20time%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%24date%20%3D%20get-date%20-Format%20MM-dd-yy-hh-mm%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Creating%20a%20folder%20in%20the%20destination%20share%20location%20to%20match%20the%20Computer%20name%20followed%20by%20Date%20and%20Time.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3Emkdir%20%24dest%5C%24hostname-%24date%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Copying%20files%20to%20the%20destination%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3ECopy-Item%20-Path%20%24Source%5C*%20-Destination%20%24dest%5C%24hostname-%24date%20-Recurse%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%221%202%203%204%205%206%207%22%20color%3D%22%23FF0000%22%3E%3CSTRONG%3EThe%20sample%20script%20provided%20here%20is%26nbsp%3Bnot%20supported%20under%20any%20Microsoft%20standard%20support%20program%20or%20service.%20All%26nbsp%3Bscripts%20are%26nbsp%3Bprovided%20AS%20IS%20without%20warranty%20of%20any%20kind.%20Microsoft%20further%20disclaims%20all%20implied%20warranties%20including%2C%20without%20limitation%2C%20any%20implied%20warranties%20of%20merchantability%20or%20of%20fitness%20for%20a%20particular%20purpose.%20The%20entire%20risk%20arising%20out%20of%20the%20use%20or%20performance%20of%20the%20sample%20scripts%20and%20documentation%20remains%20with%20you.%20In%20no%20event%20shall%20Microsoft%2C%20its%20authors%2C%20or%20anyone%20else%20involved%20in%20the%20creation%2C%20production%2C%20or%20delivery%20of%20the%20scripts%20be%20liable%20for%20any%20damages%20whatsoever%20(including%2C%20without%20limitation%2C%20damages%20for%20loss%20of%20business%20profits%2C%20business%20interruption%2C%20loss%20of%20business%20information%2C%20or%20other%20pecuniary%20loss)%20arising%20out%20of%20the%20use%20of%20or%20inability%20to%20use%20the%20sample%20scripts%20or%20documentation%2C%20even%20if%20Microsoft%20has%20been%20advised%20of%20the%20possibility%20of%20such%20damages.%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENote%3C%2FSTRONG%3E%3A%3CEM%3E%20I%20have%20specified%20a%20local%20file%20share%20which%20means%2C%20only%20machines%20that%20can%20access%20this%20network%20share%20will%20be%20able%20to%20upload%20logs.%20You%20may%20create%20separate%20shares%20based%20on%20locations%2C%20alternatively%20you%20can%20also%20choose%20an%20Azure%20storage%20path%20for%20upload.%20Additionally%2C%20a%20network%20file%20share%20also%20requires%20firewall%20port%20exceptions.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1036685203%22%20id%3D%22toc-hId-1036685203%22%3EAzure%20File%20Share%3C%2FH2%3E%0A%3CP%3EIf%20you%20are%20interested%20in%20uploading%20the%20logs%20to%20Azure%2C%20for%20devices%20outside%20corporate%20network%20managed%20via%20CMG.%3C%2FP%3E%0A%3CP%3EFirst%2C%20we%20create%20an%20Azure%20File%20Share.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ELaunch%20%3CA%20href%3D%22https%3A%2F%2Fportal.azure.com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fportal.azure.com%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ECreate%20a%20new%20Storage%20Account%20or%20use%20an%20existing%20one.%3C%2FLI%3E%0A%3CLI%3EInside%20the%20desired%20Storage%20Account%20click%20%3CSTRONG%3EFiles%3C%2FSTRONG%3E%20under%20File%20Services%3C%2FLI%3E%0A%3CLI%3EClick%20%3CSTRONG%3E%2B%20File%20share%3C%2FSTRONG%3E%20to%20add%20one%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20370px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137551i998A69D40C0A1B13%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EGive%20a%20Name%20and%20specify%20size%20in%20GB%20for%20Quota%20and%20click%20Create%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20310px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137552i02B4490A13C76A9F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EClick%20on%20the%20File%20Share%20and%20click%20%3CSTRONG%3EConnect%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20358px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137553iAC8A735C9EF74231%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CUL%3E%0A%3CLI%3ECopy%20the%20Windows%20pre-populated%20PowerShell%20command%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20429px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137554i3B5CD2A79E7FAC02%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_3%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1515471758%22%20id%3D%22toc-hId--1515471758%22%3EUpdate%20the%20Script%3C%2FH2%3E%0A%3CP%3EUsing%20the%20same%20script%20reference%20for%20file%20share%2C%20we%20can%20add%20the%20Azure%20drive%20connection%20information.%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Paste%20the%20Azure%20File%20Share%20Drive%20Connection%20Info.%20Here%3C%2FFONT%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_4%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20End%20of%20Azure%20File%20Share%20Drive%20Connection%20Info.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Specify%20destination%20share%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%24dest%20%3D%20%22Z%3A%5C%22%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Specify%20the%20ConfigMgr%20log%20file%20location%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%24source%20%3D%20%22c%3A%5Cwindows%5Cccm%5Clogs%22%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Capturing%20Machine%20Name%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%24hostname%20%3D%20hostname%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Capturing%20current%20date%20and%20time%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%24date%20%3D%20get-date%20-Format%20MM-dd-yy-hh-mm%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Creating%20a%20folder%20in%20the%20destination%20share%20location%20to%20match%20the%20Computer%20name%20followed%20by%20Date%20and%20Time.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3Emkdir%20%24dest%5C%24hostname-%24date%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Copying%20files%20to%20the%20destination%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3ECopy-Item%20-Path%20%24Source%5C*%20-Destination%20%24dest%5C%24hostname-%24date%20-Recurse%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3E%23%20Remove%20mapped%20Z%20drive%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23008000%22%3ERemove-PSDrive%20-Name%20Z%20-Force%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%221%202%203%204%205%206%207%22%20color%3D%22%23FF0000%22%3E%3CSTRONG%3EThe%20sample%20script%20provided%20here%20is%26nbsp%3Bnot%20supported%20under%20any%20Microsoft%20standard%20support%20program%20or%20service.%20All%26nbsp%3Bscripts%20are%26nbsp%3Bprovided%20AS%20IS%20without%20warranty%20of%20any%20kind.%20Microsoft%20further%20disclaims%20all%20implied%20warranties%20including%2C%20without%20limitation%2C%20any%20implied%20warranties%20of%20merchantability%20or%20of%20fitness%20for%20a%20particular%20purpose.%20The%20entire%20risk%20arising%20out%20of%20the%20use%20or%20performance%20of%20the%20sample%20scripts%20and%20documentation%20remains%20with%20you.%20In%20no%20event%20shall%20Microsoft%2C%20its%20authors%2C%20or%20anyone%20else%20involved%20in%20the%20creation%2C%20production%2C%20or%20delivery%20of%20the%20scripts%20be%20liable%20for%20any%20damages%20whatsoever%20(including%2C%20without%20limitation%2C%20damages%20for%20loss%20of%20business%20profits%2C%20business%20interruption%2C%20loss%20of%20business%20information%2C%20or%20other%20pecuniary%20loss)%20arising%20out%20of%20the%20use%20of%20or%20inability%20to%20use%20the%20sample%20scripts%20or%20documentation%2C%20even%20if%20Microsoft%20has%20been%20advised%20of%20the%20possibility%20of%20such%20damages.%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-227338577%22%20id%3D%22toc-hId-227338577%22%3EAdd%20Script%20to%20ConfigMgr%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3ELaunch%20ConfigMgr%20console%20%26gt%3B%20Software%20Library%20%26gt%3B%20Scripts%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20288px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137555iC34C75D5D32B4B5D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EFrom%20the%20ribbon%20menu%20click%20Create%20Script%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%2060px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137556iDB7C605B5D1D33BC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EProvide%20a%20script%20name%20and%20paste%20the%20script.%20(%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%3CEM%3EDon%E2%80%99t%20forget%20to%20specify%20the%20destination%20share%3C%2FEM%3E%3C%2FFONT%3E)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20632px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137557iF6DA35720CCCE8C9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Next%20to%20finish%20the%20wizard.%3C%2FLI%3E%0A%3CLI%3EApprove%20the%20Script%20for%20usage.%20%3CEM%3E(%3CFONT%20size%3D%222%22%3ECheck%20the%20Hierarchy%20Settings%20if%20Script%20authors%20require%20additional%20script%20approver.%3C%2FFONT%3E)%3C%2FEM%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1970148912%22%20id%3D%22toc-hId-1970148912%22%3ERun%20Script%20to%20capture%20logs%3C%2FH2%3E%0A%3CP%3ENow%20that%20our%20script%20is%20ready%2C%20we%20can%20execute%20this%20against%20a%20single%20device%20to%20validate.%20You%20may%20need%20to%20set%20the%20PowerShell%20execution%20Policy%20to%20Bypass%20if%20the%20scripts%20are%20not%20signed.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EFrom%20the%20ConfigMgr%20console%2C%20go%20to%20Assets%20and%20Compliance%20%26gt%3B%20Devices%3C%2FLI%3E%0A%3CLI%3EChoose%20your%20desired%20device%20and%20right%20click%20to%20choose%20Run%20Script%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20355px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137558i03486EE94F078DBC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESelect%20your%20script%20from%20the%20wizard%20and%20click%20Next%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20588px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137559iCC15F2AF04264317%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20captured%20log%20files%20should%20now%20be%20copied%20to%20the%20server%20share%20you%20specified%20in%20the%20script%20inside%20the%20folder%20matching%20the%20source%20computer%20name%20followed%20with%20date%20and%20time.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20617px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137560i40832918240D6700%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EYou%20can%20view%20the%20Azure%20logs%20directly%20from%20the%20portal%20or%20via%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Ffeatures%2Fstorage-explorer%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Storage%20Explorer%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20646px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137562iC9BFC32190168BA6%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--582008049%22%20id%3D%22toc-hId--582008049%22%3ETroubleshooting%3C%2FH2%3E%0A%3CP%3ERefer%20the%20%3CSTRONG%3Escripts.log%3C%2FSTRONG%3E%20on%20the%20client%20machine.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EThanks%2C%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EArnab%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-914386%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20is%20a%20short%20blog%20post%20about%20remotely%20capturing%20ConfigMgr%20client%20log%20files%20to%20a%20file%20share%20for%20troubleshooting%20purposes.%3C%2FP%3E%0A%3CP%3EWith%20the%20ever-increasing%20security%2C%20not%20all%20teams%20supporting%20endpoints%20necessarily%20have%20Admin%20access%20for%20troubleshooting.%20Part%20of%20which%20includes%20analyzing%20logs.%3C%2FP%3E%0A%3CP%3EYou%20may%20experience%20scenario%20where%20the%20device%20is%20not%20even%20on%20corporate%20network%20and%20you%20need%20to%20capture%20logs.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-914386%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EArnabMitra%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

This is a short blog post about remotely capturing ConfigMgr client log files to a file share for troubleshooting purposes.

With the ever-increasing security, not all teams supporting endpoints necessarily have Admin access for troubleshooting. Part of which includes analyzing logs.

You may experience scenario where the device is not even on corporate network and you need to capture logs.

 

Solution

We can use the power of Run Scripts feature to capture logs remotely against a single machine or a collection of devices and dump it against a file share for analysis.

 

Prerequisites

  • To run PowerShell scripts, the client must be running PowerShell version 3.0 or later. However, if a script you run contains functionality from a later version of PowerShell, the client on which you run the script must be running that version of PowerShell.
  • Configuration Manager clients must be running the client from the 1706 release, or later in order to run scripts.
  • To use scripts, you must be a member of the appropriate Configuration Manager security role.
  • To import and author scripts - Your account must have Create permissions for SMS Scripts.
  • To approve or deny scripts - Your account must have Approve permissions for SMS Scripts.
  • To run scripts - Your account must have Run Script permissions for Collections.

Reference: https://docs.microsoft.com/en-us/sccm/apps/deploy-use/create-deploy-scripts

 

Here’s the sample script I have use for this purpose:

# Specify destination share

$dest = "\\<server>\Share"

 

# Specify the ConfigMgr log file location

$source = "c:\windows\ccm\logs"

 

# Capturing Machine Name

$hostname = hostname

 

# Capturing current date and time

$date = get-date -Format MM-dd-yy-hh-mm

 

# Creating a folder in the destination share location to match the Computer name followed by Date and Time.

mkdir $dest\$hostname-$date

 

# Copying files to the destination

Copy-Item -Path $Source\* -Destination $dest\$hostname-$date -Recurse

 

The sample script provided here is not supported under any Microsoft standard support program or service. All scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.

 

Note: I have specified a local file share which means, only machines that can access this network share will be able to upload logs. You may create separate shares based on locations, alternatively you can also choose an Azure storage path for upload. Additionally, a network file share also requires firewall port exceptions.

 

Azure File Share

If you are interested in uploading the logs to Azure, for devices outside corporate network managed via CMG.

First, we create an Azure File Share.

  • Launch https://portal.azure.com
  • Create a new Storage Account or use an existing one.
  • Inside the desired Storage Account click Files under File Services
  • Click + File share to add one

image.png

  • Give a Name and specify size in GB for Quota and click Create

image.png

  • Click on the File Share and click Connect

image.png

 
  • Copy the Windows pre-populated PowerShell command

image.png

 

 

Update the Script

Using the same script reference for file share, we can add the Azure drive connection information.

# Paste the Azure File Share Drive Connection Info. Here

 

# End of Azure File Share Drive Connection Info.

 

# Specify destination share

$dest = "Z:\"

 

# Specify the ConfigMgr log file location

$source = "c:\windows\ccm\logs"

 

# Capturing Machine Name

$hostname = hostname

 

# Capturing current date and time

$date = get-date -Format MM-dd-yy-hh-mm

 

# Creating a folder in the destination share location to match the Computer name followed by Date and Time.

mkdir $dest\$hostname-$date

 

# Copying files to the destination

Copy-Item -Path $Source\* -Destination $dest\$hostname-$date -Recurse

 

# Remove mapped Z drive

Remove-PSDrive -Name Z -Force

 

The sample script provided here is not supported under any Microsoft standard support program or service. All scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.

 

 

Add Script to ConfigMgr

  • Launch ConfigMgr console > Software Library > Scripts

image.png

  • From the ribbon menu click Create Script

image.png

  • Provide a script name and paste the script. (Don’t forget to specify the destination share)

image.png

  • Click Next to finish the wizard.
  • Approve the Script for usage. (Check the Hierarchy Settings if Script authors require additional script approver.)

 

 

Run Script to capture logs

Now that our script is ready, we can execute this against a single device to validate. You may need to set the PowerShell execution Policy to Bypass if the scripts are not signed.

  • From the ConfigMgr console, go to Assets and Compliance > Devices
  • Choose your desired device and right click to choose Run Script

image.png

  • Select your script from the wizard and click Next

image.png

 

The captured log files should now be copied to the server share you specified in the script inside the folder matching the source computer name followed with date and time.

image.png

You can view the Azure logs directly from the portal or via Azure Storage Explorer

image.png

 

Troubleshooting

Refer the scripts.log on the client machine.

 

 

 

 

Thanks,

Arnab