none
Need Help To Automate Linux Deployment Using SCOM-2016 RRS feed

  • Question

  • I have this powershell script which imports FQDN from a csv files and automates deployment of agents on WINDOWS.

    I'm running SCOM-2016

    cls
    #Imports PowerShell Modules 
    
    import-module OperationsManager
    
    
    #Variables
    
    $InstallAccount = Get-Credential <credentials>
    $PrimaryMgmtServer = Get-SCOMManagementserver -Name <PrimaryManagementServer>
    
    
    #Connects to OpsMgr Management Group
    Start-OperationsManagerClientShell -ManagementServerName: <ManagementServerName> -PersistConnection: $true -Interactive: $true;
    
    $list = Import-Csv -Path 'C:\q\new.csv'
    
    foreach ($entry in $list)
        { 
    $computer = $entry.ServerName
    
        try
    {
        Install-SCOMAgent -Name $computer -PrimaryManagementServer $PrimaryMgmtServer -ActionAccount $InstallAccount -ErrorAction Stop
    #Writes Success message into file
    Write-Host -ForegroundColor Green  "Successfully Deployed On $computer.";
    "$computer, Success." | out-file "C:\q\new111.csv" -Append -NoClobber
            }
    
        Catch
    {
    #Writes a failure message into file
    Write-Host -ForegroundColor Red  "Failed On $computer.";
            "$computer, Failed." | out-file "C:\q\result.csv" -Append -NoClobber
    }
    
    }

    I want a similar one for Linux.

    Thank You


    • Edited by Error__401 Tuesday, August 27, 2019 5:05 AM
    • Moved by Garth JonesMVP Tuesday, August 27, 2019 12:42 PM Not a CMCB question
    Tuesday, August 27, 2019 5:03 AM

Answers

  • Hi There,

    So what you can do here in your case create a notepad with all servers name like servers.txt and loop this.

    Once you will loop this your script looks like this.

    $MyPool = Get-SCOMResourcePool “UNIX/Linux Monitoring Resource Pool”
    $SSHCredential = Get-SCXSSHCredential -UserName scom -ElevationType sudo
    
    #Provide your crednitals that has sudo access on servers and added in scom too
    $WSCredential = Get-Credential scom
    
    $Servers= Get-Content -Path C:\Temp\Servers.txt
    foreach($Server in $Servers)
    {
    # Using MSAA account this fails
    $DiscResult = Invoke-SCXDiscovery -Name $Server -ResourcePool $MyPool -WSManCredential $WSCredential -SSHCredential $SSHCredential
    
    $DiscResult |fl -property *
    
    $installResult = Install-SCXAgent -DiscoveryResult $DiscResult -Verbose
    $installResult | fl -property *
    
    }

    What I am doing here I have created a notepad file with the name servers.txt in temp folder. And my goal is to install agent on all of the servers that are in servers.txt

    Hope this helps :)


    Cheers, Gourav Please remember to mark the replies as answers if it helped.


    Wednesday, August 28, 2019 6:19 AM

All replies

  • This is a System Center *Configuration* Manager forum, not an *Operations* Manager forum. A mod may move your thread, but you should post your question in an Operations Manager forum.

    Jason | https://home.configmgrftw.com | @jasonsandys

    Tuesday, August 27, 2019 6:49 AM
  • Hi There,

    Use the given script on below link:-

    https://blogs.technet.microsoft.com/kevinjustin/2017/10/16/adding-unix-agents-via-powershell/


    Cheers, Gourav Please remember to mark the replies as answers if it helped.

    Tuesday, August 27, 2019 6:50 PM
  • Thanks GouravIN,

    I already used this script before. This following script offers you with two option, either you deploy one system at a time, we have more than 600 Linux Systems.

    $DiscResult = Invoke-SCXDiscovery -Name "ubuntu.testlab.net" -ResourcePool $MyPool -WSManCredential $WSCredential -SSHCredential $SSHCredential
    
    

    Or use this IP range to deploy, as in our infrastructure i cannot use this one

    $DiscResult = Invoke-SCXDiscovery -IPRange 192.168.1.50,192.168.1.75  -ResourcePool $MyPool -WSManCredential $WSCredential -SSHCredential $SSHCredential

    So i'm looking for some CSV which will contain all the Linux machines and will deploy agents automatically from the list, as the script i have shared for windows.


    Wednesday, August 28, 2019 3:54 AM
  • Hi There,

    So what you can do here in your case create a notepad with all servers name like servers.txt and loop this.

    Once you will loop this your script looks like this.

    $MyPool = Get-SCOMResourcePool “UNIX/Linux Monitoring Resource Pool”
    $SSHCredential = Get-SCXSSHCredential -UserName scom -ElevationType sudo
    
    #Provide your crednitals that has sudo access on servers and added in scom too
    $WSCredential = Get-Credential scom
    
    $Servers= Get-Content -Path C:\Temp\Servers.txt
    foreach($Server in $Servers)
    {
    # Using MSAA account this fails
    $DiscResult = Invoke-SCXDiscovery -Name $Server -ResourcePool $MyPool -WSManCredential $WSCredential -SSHCredential $SSHCredential
    
    $DiscResult |fl -property *
    
    $installResult = Install-SCXAgent -DiscoveryResult $DiscResult -Verbose
    $installResult | fl -property *
    
    }

    What I am doing here I have created a notepad file with the name servers.txt in temp folder. And my goal is to install agent on all of the servers that are in servers.txt

    Hope this helps :)


    Cheers, Gourav Please remember to mark the replies as answers if it helped.


    Wednesday, August 28, 2019 6:19 AM
  • Hi,

    did the reply of Gourav help? We would really appreciate your feedback on this one. 

    Thanks in advance for that!

    Regards,


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov

    Friday, September 13, 2019 8:36 AM
    Moderator