Solved

powershell script on Vcenter VLAN

Posted on 2016-10-12
1
23 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
1 Comment
 
LVL 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Virtual Footprint Extractor 1 36
That NUMA and vNUMA question 4 41
Use of Training Budget 12 64
Powershell Script Error Handling 7 31
It Is not possible to enable LLDP in vSwitch(at least is not supported by VMware), so in this article we will enable this, and also go trough how to enabled CDP and how to get this information in vSwitches and also in vDS.
This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
Teach the user how to install vSphere Update Manager  Console to Windows system:  Install vSphere Update Manager: Configure vSphere Update Manager plug-in in vSphere Client: Verify vSphere Update Manager settings in vSphere Client:
Teach the user how to configure vSphere Replication and how to protect and recover VMs Open vSphere Web Client: Verify vsphere Replication is enabled: Enable vSphere Replication for a virtual machine: Verify replicated VM is created: Recover replica…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now