locked
Issue running a PowerShell Script RRS feed

  • Question

  • HI

    I want to run script in the start of Task sequence to backup all profile.

    after I get it and tried to run the TS i get the following error:

    win32_UserProfile invalid class and this happened in the line:

    $LocalProfiles = Get-WMIObject Win32_UserProfile -filter "Special != 'true'"     of script

    when i tried to run Get-WMIObject - class Win32_UserProfile , i found the same error invalid class

    info: my boot image is support Powershell  and i can list all WMIObject

    any help



    Mahmoud

    Wednesday, August 10, 2016 10:57 AM

Answers

  • > "I want to capture all folders and files for all profile and can't do it by the built-in tools"

    Sure you can. This is exactly what USMT is for.

    > "my boot image is support Powershell  and i can list all WMIObject "

    Query the class in WinPE makes no sense though because there are no profiles in WinPE and so I doubt this class exists. Querying WMI while in WinPE does not query the OS installed on the system.

    Just use USMT.


    Jason | http://blog.configmgrftw.com | @jasonsandys

    • Proposed as answer by Narcoticoo Wednesday, August 10, 2016 2:38 PM
    • Marked as answer by Frank Dong Wednesday, September 7, 2016 11:29 AM
    Wednesday, August 10, 2016 1:23 PM

All replies

  • Why not using the built-in features to capture the user state?

    Torsten Meringer | http://www.mssccmfaq.de

    Wednesday, August 10, 2016 11:12 AM
  • I want to capture all folders and files for all profile and can't do it by the built-in tools

    thank you


    Mahmoud

    Wednesday, August 10, 2016 11:17 AM
  • Hi,

    I haven't tried it but it could be that you run the script in a Task Sequence = System context if you use PSexec and run the script on your machine in System context does it work then?

    Regards,
    Jörgen


    -- My System Center blog ccmexec.com -- Twitter @ccmexec

    Wednesday, August 10, 2016 11:23 AM
  • Mahmoud,

        Is this script executed in Windows PE environment just after the boot? How does the task sequence look like step after step?

    Wednesday, August 10, 2016 11:43 AM
  • yes, i tried it local and remotely
     as i said the issue on class Win32_UserProfile 
    which is a part on script why is not loaded on the boot image, how ever all classes are?

    Mahmoud



    Wednesday, August 10, 2016 11:51 AM

  • Mahmoud

    Wednesday, August 10, 2016 11:53 AM
  • and these was the error :


    Mahmoud

    Wednesday, August 10, 2016 11:54 AM
  • > "I want to capture all folders and files for all profile and can't do it by the built-in tools"

    Sure you can. This is exactly what USMT is for.

    > "my boot image is support Powershell  and i can list all WMIObject "

    Query the class in WinPE makes no sense though because there are no profiles in WinPE and so I doubt this class exists. Querying WMI while in WinPE does not query the OS installed on the system.

    Just use USMT.


    Jason | http://blog.configmgrftw.com | @jasonsandys

    • Proposed as answer by Narcoticoo Wednesday, August 10, 2016 2:38 PM
    • Marked as answer by Frank Dong Wednesday, September 7, 2016 11:29 AM
    Wednesday, August 10, 2016 1:23 PM
  • Thank you Jason, I'll tray it

    Mahmoud

    Sunday, August 14, 2016 7:42 AM