Quantcast
Viewing all articles
Browse latest Browse all 21975

Building a string from a Get-ADComputer output adds @{Name= to the computer name

I am creating a script to collect all the machines with certificates installed on them. After gathering what type of computer I want (based on a character in the name) I run Get-ADComputer to get my computer list.

$Servername=Get-ADComputer-LDAPFilter$ComputerTypeChoice-SearchBase"OU=servers,DC=Seatimes,DC=com"|SelectName

I then need to create a variable string that looks like this \\servername\My to place into my command to search for certificates

$Scanset=ForEach($1in$servername){"\\"+$1+"\My"} - But this is not working

If I do this with a single computer name in the variable that I create myself then it works perfect. -\\computername\My

If I do this from my Get-ADComputer output I get this - \\@{Name=servername}\My. I get that for each server in the list withservername replaced with the actual server name of course

If I run $servername | Select * I am shown the server list with just the names. This is the last line in the code to fix and I think this will work but I can't get past it. Please help

Oh and I am still a newbie to Powershell



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>