Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

powershell script on Vcenter VLAN

Posted on 2016-10-12
1
Medium Priority
?
48 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 84

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

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

Question has a verified solution.

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

Ransomware is a malware that is again in the list of security  concerns. Not only for companies, but also for Government security and  even at personal use. IT departments should be aware and have the right  knowledge to how to fight it.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
This Micro Tutorial walks you through using a remote console to access a server and install ESXi 5.1. This example is showing remote access and installation using a Dell server. The hypervisor is the very first component of your virtual infrastructu…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

916 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