Hello all, Yeah, first post and it's to ask for advice.. What a newb xD
I have more than 15 years of IT experience, but more than almost none in programing ! :D
So, here it is :
I've manage to create a winPE, with PowerShell (supposedly) enable on it... But, it doen't run...
I go to the "C" drive of the computer to run it like so :
c:\windows\system32\Windowspowershell\v1.0\powershell.exe d:\script.ps1
I also tried :
c:\windows\system32\Windowspowershell\v1.0\powershell.exe -executionpolicy bypass d:\script.ps1
In fact, if a batchfile could do what the ps script could, that would be even better !
Here's the script "big lines"
1. ask for an input (done)
2. get mac (done)
3.export results to cvs file (done)
4. enable NIC (unsure)
5. reboot computer (done)
Note that all the "done" are in PS
thi is the PS Code :
Set-ExecutionPolicy AllSigned -Force
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
$report = "$scriptPath\CMPMAC.cvs"
$hostname = Read-Host "Input Computer name"
$wmi = gwmi -Class Win32_NetworkAdapterConfiguration -ComputerName $env:COMPUTERNAME
$macAddress = $wmi.MACADDRESS
$macAddress = $macAddress[1]
if (!(test-path $report))
{
new-item -Path $scriptPath -Name CMPMAC.cvs -ItemType File -Force | Out-Null
}
Add-Content -Value "$hostname,$macAddress" -Path $report -Force
Enable-NetAdapter -Name "E*"
#shutdown -s -r 0
Please Help me... (you are my only hope ?)
Edited by Nezcroc, 05 June 2021 - 11:33 AM.



Back to top







