Jump to content











Photo
- - - - -

PowerShell v2.0 for Win7PE


  • Please log in to reply
30 replies to this topic

#1 2aCD

2aCD

    Frequent Member

  • .script developer
  • 345 posts
  •  
    Germany

Posted 05 February 2011 - 11:49 PM

Here is my PowerShell-Addon for all PowerShell-freaks.
It is new and I hope it works ok.
I have only tested with Win7_x86, but it should also work with x64-Source.

Powershell v2.0 not work without DotNet Framework!

Download:

Attached File  Powershell.7z   35.46KB   109 downloads

Place it in Addons.

regards
2aCD

#2 2aCD

2aCD

    Frequent Member

  • .script developer
  • 345 posts
  •  
    Germany

Posted 06 February 2011 - 10:51 AM

Oh sorry It has slipped a little error.
I forgott an "End".

I have correct this and upload a new file.
(Thanks ChrisR)


regards
2aCD

#3 skyide

skyide

    Frequent Member

  • Advanced user
  • 218 posts
  •  
    Australia

Posted 06 February 2011 - 11:02 AM

Hi, Ludovici's PowerShell script is over a meg in size and this is a few KBs. I am just a bit cautious. How well has this been tested?

#4 2aCD

2aCD

    Frequent Member

  • .script developer
  • 345 posts
  •  
    Germany

Posted 06 February 2011 - 11:30 AM

Hi skyide
This is WIN7 only. It will copy all files from the source. Required registry entries are not so much. Needs, of course DotNet. The files I have kept to the list from Microsoft. I tested it with little scripts. I'm glad if someone can test it also.

#5 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 07 February 2011 - 09:06 PM

I tested it in x86 and x64, the script works well for both :dubbio:

However, I have a small problem at startup of Powershell module (look picture), I do not know any more, but the commands I tried worked well.
Powershell.exe directly works well, Maybe an additional shortcuts.

Attached Files



#6 2aCD

2aCD

    Frequent Member

  • .script developer
  • 345 posts
  •  
    Germany

Posted 08 February 2011 - 01:24 PM

Hi ChrisR,
.Net Runtime is enabled?

PowerShell has a task – Import System modules. This will immediately start to import all modules that are located in
%Systemroot%\System32\WindowsPowerShell\v1.0\Modules.

I think this error comes from applocker-modul.
Is this modul correct loaded.

wich modules are loaded? (get-module)
Attached File  PowerShell.jpg   32.76KB   15 downloads

I also can delete the paramer -ImportSystemModule.
But I think its not the best way.

#7 ludovici

ludovici

    Silver Member

  • .script developer
  • 610 posts
  • Location:France
  •  
    France

Posted 08 February 2011 - 01:48 PM

Hello 2acd :smiling9:
Without netframework script, in default chrisr winpe_se project (full copy & standard copy); mscoree.dll is missing

#8 skyide

skyide

    Frequent Member

  • Advanced user
  • 218 posts
  •  
    Australia

Posted 11 February 2011 - 10:22 PM

I think there is a problem with this script. Inside the script there are many 64 hard coded references and I get this error when I try to run the script:


DirCopy - Failed to copy directory [%BaseDir%\Temp\Win7PE_SE\1Mount\InstallWimSrc\Windows\SysWow64\Windowspowershell\*] to: [%BaseDir%\Target\Win7PE_SE\Windows\SysWow64\WindowsPowerShell]: + s

 [Info] [//]


My Win7 is a 32 bit ultimate.

#9 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 12 February 2011 - 09:44 AM

strange,:thumbup:

The script copy

DirCopy,"%InstallSRC%\Windows\SysWow64\Windowspowershell\*","%TargetDir%\Windows\SysWow64\WindowsPowerShell"
Only If the folder %TargetDir%\Windows\SysWow64 exist.

You should have an another script that create this folder. This folder SysWow64 must not exist in x86
I have no issue on my side

:cheers:

#10 skyide

skyide

    Frequent Member

  • Advanced user
  • 218 posts
  •  
    Australia

Posted 12 February 2011 - 10:09 AM

Hmm I have "WoW64 Basic" script selected by default in WIN7PE_SE under Build. In its UI it only lists 64 OEMs as a source. I wonder if it somehow the problem is related to this?

UPDATE: It is not. I deleted the script and tried again enabling the Power Shell 2 script. Got the same error. For now, I will stick with the original Power Shell v1 - seems to work fine.

#11 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 12 February 2011 - 10:43 AM

No, the script "WoW64 Basic" does nothing in x86 building.

In your case, the folder SysWow64 is probably create from another script that you added before this one :thumbup: .
At home, it does not exist in my full x86 building.

Anyway, I changed a little the script to test SysWow64 from the source "%InstallSRC%\Windows\SysWow64" Instead of "%TargetDir%\Windows\SysWow64"
:cheers:

Edit : Adding some mui and mscoree.dll !, if not already exist.

Attached Files



#12 2aCD

2aCD

    Frequent Member

  • .script developer
  • 345 posts
  •  
    Germany

Posted 12 February 2011 - 11:16 AM

Have do you run powershell at addons (new components)?
No folder SysWow64 are copyed with x86 source, before powershell (placed in addons (new components) is running.

For test you can rename the powershell-script to 1-powershell. Now the same error?
You also rename the other addons to locate the problem-script, that copy the SysWow64 folder.

@ChrisR
Yes it is better to check sorce instead target, but I am also interested in the cause of the problem. :thumbup:

regards
2aCD

#13 skyide

skyide

    Frequent Member

  • Advanced user
  • 218 posts
  •  
    Australia

Posted 12 February 2011 - 11:56 AM

Ok I am using Win7PE_SE_2011_02_10 as a source (and it has the new folder Components) but I also have various other scripts under my own folder "Additional" not part of WIN7_PE. I have not tried vanilla WIN7PE_SE to see whether I still get the error. If others work, mine should too. I will remove "Additional" and see if I get the error. If I don't then I will roughly know where the error is.


I renamed, MSPowerShell.Script (in Components) to 1-powershell.script but unfortunately I got the error again. I am now trying ChrisR's mod. Unfortunately it is getting quite late here (10:54PM) and will have to report back in the morning (Australia) or evening (through out Europe). I am about to leave the build to continue and leave my laptop on. Thanks!

#14 2aCD

2aCD

    Frequent Member

  • .script developer
  • 345 posts
  •  
    Germany

Posted 12 February 2011 - 05:29 PM

Hi skyide,

now replace the line
If,EXISTDIR,%tWow%,Run,%ScriptFile%,CopyFiles_SySWoW64
with
If,%SourceArch%,Equal,x64,If,EXISTDIR,%Wow%,Run,%ScriptFile%,CopyFiles_SySWoW64]
I hope this resove the errors

sorry removed (buggy)

regards
2aCD

#15 skyide

skyide

    Frequent Member

  • Advanced user
  • 218 posts
  •  
    Australia

Posted 12 February 2011 - 09:17 PM

Update: ChrisR's changes work! Thanks!

I am also now testing 2aCD's change above. I will report as soon as the build gets completed.

#16 skyide

skyide

    Frequent Member

  • Advanced user
  • 218 posts
  •  
    Australia

Posted 13 February 2011 - 12:40 AM

Hi 2aCD

I just tested your changes but the error remains. ChrisR's changes however fixed the error.

Thanks for your help to both of you though.

If you still want me to test stuff, let me know what you want me to change and I will test it.

#17 2aCD

2aCD

    Frequent Member

  • .script developer
  • 345 posts
  •  
    Germany

Posted 13 February 2011 - 09:38 AM

Hi skyide,

sorry, I don't make chanches it the night.
It's better in the morning.
I have correct this errors und upload v4

Attached File  MsPowerShell.7z   35.68KB   47 downloads

I hope, now run build without errors.

regards
2aCD

#18 skyide

skyide

    Frequent Member

  • Advanced user
  • 218 posts
  •  
    Australia

Posted 14 February 2011 - 09:57 AM

Hi 2aCD,

I tested your changes. Good work! It works :cheers:

#19 goldfinger

goldfinger
  • Members
  • 9 posts

Posted 24 September 2011 - 02:04 PM

I tried to run Powershell V2 on WinPE 3.1 x64 using WinBuilder 082 using the last updates of the script package .Net v.6 and Powershell v.3

Problem 1:
.Net Framework64 install problem on x64 with .Net 2.0 only

I can't use .Net 2.0 only version because auf an error:

Run - Processed section [CopyNet2.0Core] in file: [%BaseDir%\Projects\Win7PE_SE\Components\DotNetFx.script]
FileCopy - Copied [%BaseDir%\Workbench\Common\Win7Extract\InstallWimSrc\Windows\Microsoft.NET\Framework64\v2.0.50727\AppLaunch.exe] to: [%BaseDir%\Target\Win7PESE\Windows\Microsoft.NET\Framework64\v2.0.50727]
FileCopy - File exists [%BaseDir%\Workbench\Common\Win7Extract\InstallWimSrc\Windows\Microsoft.NET\Framework64\v2.0.50727\CLR.mof] to: [%BaseDir%\Target\Win7PESE\Windows\Microsoft.NET\Framework64\v2.0.50727]: Overwritten
FileCopy - Failed to copy [%BaseDir%\Workbench\Common\Win7Extract\InstallWimSrc\Windows\Microsoft.NET\Framework64\v2.0.50727\CasPol.*] to: [%BaseDir%\Target\Win7PESE\Windows\Microsoft.NET\Framework64\v2.0.50727\]: "the directory name is invalid."
Halt
There is a file named "v2.0.50727" on the target directory and the copy action is aborted.
It seems that the directory "v2.0.50727" was not created before under Framework64.
[CopyNet2.0Only]
Run,%ScriptFile%,CopyNet2.0Core // maybe it should called Run,%ScriptFile%,CopyNet2.0Core,#1 OR create the missing dir before


Not sure which framework version should I use but in the next step I choosed "Full without Reference Assemblies run from RAM"

Problem 2:
32 Bit Powershell under x:\windows\syswow64\windowspowershell\v1.0\powershell.exe is not running correctly.
Because entries under HKLM\software\Wow6432Node\microsoft\powershell\... have a wrong path c:\windows\ instead of x:\windows\
After fixing this manual with regedit no error messages appear.

Problem 3:
I tried 64-Bit Powershell in the x:\windows\system32\windowspowershell\v1.0\powershell.exe directory.
But it says that there is no .Net Framework installed.
"Version v2.0.50727 of .Net Framework is not installed and it is required to run version 1 of Windows PowerShell."

#20 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 25 September 2011 - 10:00 PM

Hi goldfinger,

thank you for your feedback :thumbsup:

Problem 1:
.Net Framework64 install problem on x64 with .Net 2.0 only

I can't use .Net 2.0 only version because auf an error:

Corrected by adding #1 (the folder ...\Framework64\... are created before the copy, with this parameter ) in

[CopyNet2.0Only]

 Run,%ScriptFile%,CopyNet2.0Core,#1

Problem 2:
32 Bit Powershell under x:\windows\syswow64\windowspowershell\v1.0\powershell.exe is not running correctly.
Because entries under HKLM\software\Wow6432Node\microsoft\powershell\... have a wrong path c:\windows\ instead of x:\windows\

Corrected in software_x64.reg

Here are the two scripts fixed, thanks :)

Attached File  DotNetFx-MsPowerShell.7z   36.78KB   24 downloads

Problem 3:
I tried 64-Bit Powershell in the x:\windows\system32\windowspowershell\v1.0\powershell.exe directory.
But it says that there is no .Net Framework installed.
"Version v2.0.50727 of .Net Framework is not installed and it is required to run version 1 of Windows PowerShell."

I do not know much about powershell to test it, in x64 with "DotNet 2.0 only", it not seem to work correctly.
I tried basic commands powershell in x64 build with the option dotNet "full without Reference Assemblies", It seems to work better.

Attached File  Powershell_x64.png   749.12KB   19 downloads

Regards,
Chris

:cheers:

#21 goldfinger

goldfinger
  • Members
  • 9 posts

Posted 07 October 2011 - 11:25 AM

I tried your new scripts still I get the same error that .Net Framework is not installed with 64-Bit Powershell.
I noticed that there are no entries under:
HKLMSoftwareMicrosoftFusionNativeImagesIndexv2.0.50727_64
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionSideBySideWinnersamd64_microsoft-windows-powershell-....

Do you have any entries there?

Thanks

#22 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 07 October 2011 - 09:23 PM

I tried your new scripts still I get the same error that .Net Framework is not installed with 64-Bit Powershell.
I noticed that there are no entries under:
HKLMSoftwareMicrosoftFusionNativeImagesIndexv2.0.50727_64
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionSideBySideWinnersamd64_microsoft-windows-powershell-....

Do you have any entries there?

Thanks

In fact, it seems to lack some key in x64 build. have you tried by adding them ?

I hope this is not a .Net issue and that the missing keys will be enough, Dotnet remains difficult in PE Grrrrrrrr
I try to add these keys to software_x64.reg and provide you soon a new script for test.

:cheers:

#23 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 07 October 2011 - 11:42 PM

Hi goldfinger,

I added keys which seemed to miss in x64 build (software_x64.reg)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion\NativeImagesIndex\v2.0.50727_64
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\amd64_microsoft-windows-gpowershell
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners\amd64_microsoft-windows-powershell
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\PowerShell
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\WSMAN\Plugin\Microsoft.PowerShell32

Can you try it again and give me feedback.

Attached File  MsPowerShell.7z   23.05KB   24 downloads

Happy testing :)

#24 goldfinger

goldfinger
  • Members
  • 9 posts

Posted 10 October 2011 - 11:14 AM

Hi ChrisR,

I tried it without success.
I have a logfile of sysinternals procmon 2.96 which I can send you. Don't see I can upload it here.
There are no files under x:windowswinsxs but I don't think they are needed because the x86 and msil files of powershell are missing, too.
And SidebySide is not supported by WinPe.
It seems more to be a .NET Framework problem.

#25 goldfinger

goldfinger
  • Members
  • 9 posts

Posted 10 October 2011 - 12:24 PM

I added the powershell winsxs files and still the same error. No .NET Framework installed.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users