/build/static/layout/Breadcrumb_cap_w.png

Powershell Command | Out-File

Problem: Determine remote computers Data Execution Prevention (DEP) status and pipe the results to a txt file including the machine name.

Current Solution: BCDEdit /enum "{current}" | out-file \FILESHARE\DEP\DEP.txt -Append

I'm pushing the script out through SCCM so my only issue is getting the machine name included with the results. SCCM allows you to run the script on each machine remotely as System so I don't have to worry about "get-content" with a list of PC's just point to a collection and run the script on those systems.

Alternatively, I tried to run Powershell command outside of SCCM such as:

$XenServers = get-content -path 'C:\PC_List.txt'

$Results= ForEach ($XenServer in $XenServers) { BCDEdit /enum "{current}" }

$Results | Out-File \FILESHARE\DEP\DEP.txt


0 Comments   [ + ] Show comments

Answers (2)

Posted by: SMal.tmcc 4 years ago
Red Belt
1

use wmic

wmic OS Get DataExecutionPrevention_SupportPolicy, csname > \FILESHARE\DEP\DEP.txt

Posted by: rad33k 4 years ago
Fourth Degree Brown Belt
0

You can try this one:

-join "Computer Name: `t`t $($env:COMPUTERNAME)", $(BCDEDIT /enum "{current}"),$("-"*80) | Out-File \FILESHARE\DEP\DEP.txt -Append
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ