Help with PS Project

Tagged: 

This topic contains 16 replies, has 5 voices, and was last updated by Profile photo of Justin Justin 5 days, 20 hours ago.

  • Author
    Posts
  • #57946
    Profile photo of Justin
    Justin
    Participant

    Hello All! I need help with my powershell project.

    Goal Overview:

    1) Get all of the systems Hardware IDs and Device IDs

    2) Look through all the Hardware IDs and Device IDs and when it makes a match, it'll go and execute a specific driver.

    2a) If the Hardware ID or Device ID gets a match, check to see if the drivers / software is already installed, if they are continue on with the script.

    2b) When a driver / software gets installed and it needs to restart, restart the system and continue where the driver / software left off.

    The purpose for this script(s) is to get the entire collection of Hardware IDs and Device IDs of a system and write the output to a file so it can install motherboard drivers and software. Next, I need the script to read the output and if it makes a match with one of the IDs, install the appropriate driver / software.

    While installing the drivers / software — for example the chipset drivers (this requires a restart), I need the system to restart. When it gets back into Windows, I need the script to start and continue where it left off(This is the scripts POV in my head– Oh I just finished installing the Chipset driver, next on my list is Audio, let me continue installing the drivers/software)

    I hope my goal makes sense to you all. To get the Hardware IDs and Device IDs, I downloaded and imported this module — https://gallery.technet.microsoft.com/scriptcenter/Device-Management-7fad2388 <——- Are there built in commands I can run to get the same output without loading a module?

  • #57988
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant

    Hmmm .... for how many different devices do you want to do that? Usually in an enterprise environment there is a limited amount of different hardware types and they can be provided with a prepared set of drivers.

  • #58033
    Profile photo of Justin
    Justin
    Participant

    We (my company) uses many different vendors for motherboards (ASUS, GIGABYTE, MSI, ASROCK, and Laptops)

  • #58036
    Profile photo of Richard Siddaway
    Richard Siddaway
    Moderator

    Why don't you want to use the module?

    PowerShell functionality is delivered by modules.

    • #58037
      Profile photo of Olaf Soyk
      Olaf Soyk
      Participant

      Get-CimInstance -ClassName Win32_PnPDevice or Get-WmiObject -Class Win32_PnPDevice might deliver what you're looking for.

  • #58045
    Profile photo of Justin
    Justin
    Participant

    Now, To match the hardware id's with the drivers, to me seems like the easiest part. How would I delegate the install process? How would I continue where I left off after a restart?

  • #58051
    Profile photo of Ron
    Ron
    Participant

    You'll need to create a task list that includes a status (Not started, rebooting, complete, etc) and store it in a file. Then you can pick up at the next step when the script restarts. You'll probably need to create a scheduled task that runs after startup to kick off the script each time.

  • #58057
    Profile photo of Justin
    Justin
    Participant

    Is there a good tutorial on this? This seems confusing to me

  • #58058
    Profile photo of kvprasoon
    kvprasoon
    Participant

    If you have PoweShell v 3.0 or Higher, better go through below article which may help you in Restarts.

    https://technet.microsoft.com/en-us/library/jj149010.aspx

    Thanks,
    kvprasoon

  • #58117
    Profile photo of Justin
    Justin
    Participant

    Can someone tell me if I am doing this wrong? Am I allowed to create a scheduled job and call the next workflow below it on the next startup?

    
    workflow Install-Chipset {
            Start-Process C:\Chipset\Setup.exe -ArgumentList "-s"
    }
    
    $AtStartup = New-JobTrigger -AtStartup
    
    Register-ScheduledJob -Name Chipset -Trigger $AtStartup -ScriptBlock { Install-Audio }
    
    Restart-Computer
    
    workflow Install-Audio {
            Start-Process C:\Audio\Setup.exe -ArgumentList "-s"
    }
    
  • #58210
    Profile photo of Justin
    Justin
    Participant

    Anyone?

    • #58222
      Profile photo of kvprasoon
      kvprasoon
      Participant

      Hi Justin,

      Wworkflows has the ability to continue on restarts and is the main advantage of using it. Scheduled jobs are not required here.
      You could please go through below Blog post by Richard.

      regards,
      kvprasoon

  • #58303
    Profile photo of Justin
    Justin
    Participant

    @kyprasoon

    That article was a good read. I followed it and I am still having issues. When I first run the work flow , the system will restart, everything seems good. When I log back in, the job is still suspended even though I tell it to resume on logon. Below is a copy of my code:

    Workflow Install-Chipset {
        Start-Process Notepad.exe
    
        Restart-Computer -Wait
        
        Get-Process | Out-File c:\test.txt
    
        }
    
        $action = '-NonInteractive -NoLogo -WindowsStyle Normal -NoProfile -NoExit -Command "&"C:\psworkflow.ps1"'
        $pstart = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
        Get-ScheduledTask -TaskName Install | Unregister-ScheduledTask -Confirm:$false
        $act = New-ScheduledTaskAction -Execute $pstart -Argument $action
        $trig = New-ScheduledTaskTrigger -AtLogOn
    
        Register-ScheduledTask -TaskName Install -Action $act -Trigger $trig -RunLevel Highest
    
        Install-Chipset 

    ______

    This is what I run in the "psworkflow.ps1" file at logon:

    Import-Module PSWorkflow
    Get-Job | Resume-Job
    
    
  • #58325
    Profile photo of kvprasoon
    kvprasoon
    Participant

    Still you miss the point of Workflows, No need of using Scheduled tasks wen we have workflows.
    I'm sure you will be able to make it, adding one more reference , must read and try and implement it in your way for your task

    regards,
    kvprasoon

  • #58333
    Profile photo of Justin
    Justin
    Participant

    I still cannot get it to resume on it's own. I always have to manually type it in powershell. When I go to the task scheduler and right click run, it will not perform the task.

    I am also in Audit mode with sysprep. I don't see this being an issue.

  • #58845
    Profile photo of Justin
    Justin
    Participant

    Can anyone please help me out? I cannot get my job to resume after logging on after a restart

You must be logged in to reply to this topic.