Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8819031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:15:03+00:00 2026-06-14T05:15:03+00:00

Alright there seems to be several issues with the script and i can’t seem

  • 0

Alright there seems to be several issues with the script and i can’t seem to figure out any of them, also some feedback on the script would be greatly apperciated. This is still my first script so it probably needs lots of little tweaks so please tell me whatever suggestions comes to mind.

Issues: Mostly all issues revolve around the logging.

  1. Log file is not being checked so the script keeps adding computers to the log file over and over.

  2. The log file does not update the information that is generated such as os,mac,ip, etc.

Issues Being Displayed:

Property ‘Result’ cannot be found on this object. Make sure that it
exists. At W:\Powershell Scripting\Test Lab\TestFunction.ps1:86
char:17
+ IF ($Computer. <<<< Result -ne “Successful”) {
+ CategoryInfo : InvalidOperation: (.:OperatorToken) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFoundStrict

The Script

Set-PSDebug -strict
Set-StrictMode -Version latest
$consoleObject = (Get-Host).UI.RawUI

# Adjustable Variables
$Computers_Path = ".\computers.txt"
$Log_Path = ".\Log.txt"
$Log_MaxTick = 5
$RunOnServers = 0

# Multi-Threading Variables
$Jobs_MaxAtOnce = 20
$SleepTimer = 500

# Script Specific Variables
$ScriptTitle = "Local Admin Check"

# Validate Adjustable Variables
$Computers = @(Import-CSV $Computers_Path -header "Name","MAC")

# Framework Specific Variables (Pre-Setting Variables)
$Run = 0; $Succssful = 0; $Jobs_Count = 0; $Log_Tick= 0; $WriteToLog = "No"

# Misc
$Total = $Computers.length
IF (!(Test-Path $Log_Path)) { Add-Content $Log_Path "Name,OS,Mac,IPAddress,Status,Attempts,Result,LastAttempt" }
$Log = @(Import-Csv $Log_Path)
$Successful = ($Log | Where-Object {$_.Result -eq "Successful"} | Select-String -inputobject {$_.Name} -pattern $Computers | Measure-Object).Count

# Load Functions
Function GetOS {
    $RegCon = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computer.Name )
    $RegKey = $RegCon.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\")
    $RegValue = $RegKey.GetValue("ProductName")
    $RegCon.Close()
    $Computer.OS = $RegValue
}

Function SmartLogging {

    If ($Args[0] -eq "AddComputer") {
        Add-Content ($Computer.Name + "," + $Computer.OS + "," + $Computer.Mac + "," + $Computer.IPAddress + "," + $Computer.Status + "," + $Computer.Attempts + "," + $Computer.Result + "," + $Computer.LastAttempt) -path .\log.txt
    } ELSEIF ( $Log_Tick -eq $Log_MaxTick -OR $Args -eq "Update" ) {
        $Log_Tick = 0;
        Get-Content $Log_Path | Foreach-Object {$_ -replace "$Computer.Name,.*", ($Computer.Name + "," + $Computer.OS + "," + $Computer.Mac + "," + $Computer.IPAddress + "," + $Computer.Status + "," + $Computer.Attempts + "," + $Computer.Result + "," + $Computer.LastAttempt)} | Set-Content $Log_Path
    } ELSEIF ($Args[0] -eq "CheckComputer") {
         IF (!($Log | Select-String -pattern $Computer.Name -SimpleMatch)) {
            $Log += New-Object PSObject -Property @{ Name = $Computer.Name; OS = $NULL; Mac = $Computer.MAC; IPAddress = $NULL; Status = $NULL; Attempts = 0; Result = $NULL; LastAttempt = $NULL;}
            $Computer = $Log | Where-Object {$_.Name -eq $Computer.Name}
            SmartLogging AddComputer
        } ELSE {
            $Computer = $Log | Where-Object {$_.Name -eq $Computer.Name}
        }
    } ELSEIF (-not $Args[0]) {
        "Log Ticked"
        $Log_Tick++
    }
}

Function GetIPAddress {
    $IPAddress = [System.Net.Dns]::GetHostAddresses("TrinityTechCorp") | Where-Object {$_.IPAddressToString -like "*.*.*.*"};
    $Computer.IPAddress = $IPAddress.IPAddressToString
}

Function WindowTitle {
    [int]$Successful_Percent = $Successful / $Total * 100
    $consoleObject.WindowTitle = “$ScriptTitle - $Successful Out Of $Total ($Successful_Percent%) Successful `| Run`: $Run”
}

# Start Script
while ( $Successful -le $Total ) {
    $Run++
    ForEach ($Computer in $Computers) {
        WindowTitle 
        SmartLogging CheckComputer
        IF ($Computer.Result -ne "Successful") {
            IF (test-connection $Computer.Name -quiet ) {
                $Computer.Status = "Awake"
                IF (!$Computer.OS){GetOS}
                IF (!$Computer.IPAddress){GetIPAddress}
                ## Start Script ##
                    $CheckComputer = [ADSI]("WinNT://" + $Computer.Name + ",computer")
                    $Group = $CheckComputer.psbase.children.find("Administrators")
                    $members= $Group.psbase.invoke("Members") | %{$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
                    ForEach($user in $members) {
                        $Result = $Computer.Name + "," + $user.ToString()
                        Add-Content $Result -path .\Result.csv
                    }
                ## End Script ##
                SmartLogging Update
                $Computer.Result = "Successful"
                $Successful += 1
            } ELSE {
                $Computer.Status = "Unknown"
            }
            $Computer.Attempts = [int] $Computer.Attempts + 1
            $Computer.LastAttempt = Get-Date -uFormat "%I:%M:%S%p %d%b%y"
        }
    SmartLogging
    }
}
Write-Output "Script Completed"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:15:04+00:00Added an answer on June 14, 2026 at 5:15 am

    This declaration of $Computers collection….

    $Computers = @(Import-CSV $Computers_Path -header "Name","MAC")
    

    …will not work with this condition:

    IF ($Computer.Result -ne "Successful")
    

    The exception message explicitly states this, and where:

    Property ‘Result’ cannot be found on this object. Make sure that it exists. \TestFunction.ps1:86 char:17

    To resolve this, I would recommend initializing the property of Result, most likely like so:

    $Computers = @(Import-CSV $Computers_Path -header "Name","MAC","Result")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Flash 10/AS3, I added some sound and it seems to be working alright,
In android I can't figure out why this cursor is empty in htc wildfire.
Alright everyone, is there a way to have 2 divs taking up 50% of
Alright, so i have an Activity. In the activity there is a textview and
Alright I don't see why this isnt working. It seems pretty simple. Here is
Alright I created some custom classes for my project sourced from this tutorial ,
Alright, so I wrote a custom VMR9 Allocator/Presenter which seems to work fine. However,
Alright, this problem seems to be way above my head! I have this code:
Alright, database stuff is turning out to be my rails weakpoint. I have 3
Alright, what I'm trying to do is print out a few lines of text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.