Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

powershell script on Vcenter VLAN

Posted on 2016-10-12
1
Medium Priority
?
42 Views
Last Modified: 2016-10-13
Scenario: run my powerhell script on all virtual machines connected to VLAN 10.X.X.15, in Vcenter?
The script I want to run is the following:
(Get-Content C:/sample.txt -TotalCount 1) | Set-Content C:/sample.txt

What would be my best option?

Best Regards
0
Comment
Question by:Maniman man
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 83

Accepted Solution

by:
David Johnson, CD, MVP earned 2000 total points
ID: 41841152
many many possible solutions

you need to make up a list of the machines you wish to query. Using this list you can use Powershell Remoting or as an administrator connect to the c$ administrative share..

one possible solution

$computers = get-adcomputer -Filter *
foreach($computer in $computers){
write-output $computer.Name


    if((Test-Connection $computer.name -Count 1 -ErrorAction SilentlyContinue)){
        $pathtotest = "\\" + $computer.name + "\c$\sample.txt"
        if ((Test-Path $pathtotest) -eq $true){
        get-content $pathtotest -TotalCount 1 | set-content $pathtotest
            }
            else {
            write-output ($pathtotest + ' :Not found')
            }
        }
}

Open in new window

1

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Teach the user how to rename, unmount, delete and upgrade VMFS datastores. Open vSphere Web Client: Rename VMFS and NFS datastores: Upgrade VMFS-3 volume to VMFS-5: Unmount VMFS datastore: Delete a VMFS datastore:
Teach the user how to convert virtaul disk file formats and how to rename virtual machine files on datastores. Open vSphere Web Client: Review VM disk settings: Migrate VM to new datastore with a thick provisioned (lazy zeroed) disk format: Rename a…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question