none
powershell together RRS feed

  • Question

  • Greeting,

    need help for powershell.

    I have 3 powershell scripts, they are working very good.

     setusergrproup.ps1  USERNAME  GROUPNAME

     setuserhomefolder.ps1 USERNAME HOMEFOLDER

     setuserprinter.ps1 USERNAME PrintName.

    I am looking for a way to put this together, do NOT want to make any changes

    like a DOS batch file, if it is possible.

    thanks and Best Regards,

    newbie in powershell

    Monday, June 19, 2017 3:08 PM

Answers

  • Create a new script that has those three lines in it, and then run the new script.

    Use the param() statement at the top of your new script to define the username, groupname, homefolder, and printname parameters. Set them as mandatory so that PowerShell will prompt you if you forget one of them. Example:


    param(
      [parameter(Mandatory=$true)]
      [String] $UserName,
      [parameter(Mandatory=$true)]
      [String] $GroupName,
      [parameter(Mandatory=$true)]
      [String] $HomeFolder,
      [parameter(Mandatory=$true)]
      [String] $PrintName
    )
    
    SetUserGroup.ps1 $UserName $GroupName
    SetUserHomeFolder.ps1 $UserName $HomeFolder
    SetUserPrinter.ps1 $UserName $PrintName
    


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by userausera Monday, June 19, 2017 3:24 PM
    Monday, June 19, 2017 3:19 PM
    Moderator

All replies

  • Create a new script that has those three lines in it, and then run the new script.

    Use the param() statement at the top of your new script to define the username, groupname, homefolder, and printname parameters. Set them as mandatory so that PowerShell will prompt you if you forget one of them. Example:


    param(
      [parameter(Mandatory=$true)]
      [String] $UserName,
      [parameter(Mandatory=$true)]
      [String] $GroupName,
      [parameter(Mandatory=$true)]
      [String] $HomeFolder,
      [parameter(Mandatory=$true)]
      [String] $PrintName
    )
    
    SetUserGroup.ps1 $UserName $GroupName
    SetUserHomeFolder.ps1 $UserName $HomeFolder
    SetUserPrinter.ps1 $UserName $PrintName
    


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by userausera Monday, June 19, 2017 3:24 PM
    Monday, June 19, 2017 3:19 PM
    Moderator
  • Thanks you very very much!
    Monday, June 19, 2017 3:25 PM