Can powershell do this?

This topic contains 4 replies, has 3 voices, and was last updated by Profile photo of Justin Justin 4 days, 2 hours ago.

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

    Scenario:
    I have an output file that has the following inside of it:
    Product A
    Product B
    Product C

    I can have powershell say: If (Product A) then execute this If (Product B) then execute this If (Product C) then execute this
    But what is the best way to have it copy Products A-C from ServerA to Client A, then execute Product A, B, and C in order? When I say execute I mean install(Products A,B,C are programs)

    Would a switch be the best path?

    Switch ($products)
    Product A {} 
    Product B {} 
    Product C {}
    
    
  • #58391
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant

    Are you still trying to re-invent the wheel? 😉 You really should have a look to the Microsoft Deployment Toolkit. It is made for scenarios like yours. And it will make your life easier.

    To copy files oder folders you can use 'Copy-Item' or if it's more than just a few files you should use 'robocopy'.

  • #58399
    Profile photo of Justin
    Justin
    Participant

    I'm sorry but installing just the INF drivers isn't going to be the best route for my situation

  • #58403
    Profile photo of Richard Diphoorn
    Richard Diphoorn
    Participant

    Hi Justin, PowerShell can do a lot of things. Yes, a switch statement could solve your problem. But, to understand your challenge, please provide us some code that you already tried to provide you some assistance.

  • #58843
    Profile photo of Justin
    Justin
    Participant
    $MB_NAME = Get-WmiObject win32_baseboard | select -ExpandProperty Product 
    
    Switch ($MB_NAME) {
    
    "P7xxDM2(-G)                     " {Copy-Item ".\folder" "C:\Users\Test\Desktop\Install" -Recurse -Verbose -Force; Break} 
    "Placeholder" {Copy-Item ".\folder" "C:\Users\Test\Desktop\Install" -Recurse -Verbose -Force; Break} 
    "Placeholder" {Copy-Item ".\folder" "C:\Users\Test\Desktop\Install" -Recurse -Verbose -Force; Break} 
    "Placeholder" {Copy-Item ".\folder" "C:\Users\Test\Desktop\Install" -Recurse -Verbose -Force; Break} 
    Default {"Motherboard not found"; break}
    
    

    After it is finished copying over the files, what is the best way to tell the system to continue and install the ".\folder" powershell script?

You must be logged in to reply to this topic.