Need powershell script

Welcome Forums General PowerShell Q&A Need powershell script

This topic contains 1 reply, has 2 voices, and was last updated by

1 year, 1 month ago.

  • Author
  • #97735

    Topics: 1
    Replies: 0
    Points: 0
    Rank: Member

    Need a powershell code to remove the list of servers in first file based on the second file details. The second file contains the list of the server details that needs to be removed in the first file. Both the files will be in CSV format. As I am new to scripting please edit the script and provide the same.
    Error "Method invocation failed because [System.Management.Automation.PSCustomObject] doesn't contain a method named 'IndexOf'".
    As Iam new to scripting please reframe the script and provide it.

    $serverlist_csv1 = Import-Csv -Path $file1
    $serverlist_temp1 = $serverlist_csv1
    $exclude_serverlist_csv = Import-Csv -Path $file2
    foreach ($server in $exclude_serverlist_csv) {
    $servers1 = ($serverlist_csv1.'SourceHostName' | Select-Object -ExcludeProperty 'SourceHostName')

    if ($servers1 -contains $server.'Exclude Server') {
    $server_object1 = ($serverlist_csv1 | Where-Object {$_.SourceHostName -eq $server.'Exclude Server'})

    $serverindex1 = $serverlist_csv1.IndexOf($server_object1)
    $dataResizable1 = {$serverlist_csv1}.Invoke()
    $serverlist_csv1 = $dataResizable1

  • #97737

    Topics: 13
    Replies: 48
    Points: 0
    Rank: Member

    which columns and headers do you have in your csv files?

    also, please try to run each line in a time, to figureout when the problem is occurred.

    this is the first step for troubleshoot...

The topic ‘Need powershell script’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort