Solved

powershell script on Vcenter VLAN

Posted on 2016-10-12
1
39 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 82

Accepted Solution

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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Teach the user how to install and configure the vCenter Orchestrator virtual appliance Open vSphere Web Client: Deploy vCenter Orchestrator virtual appliance OVA file: Verify vCenter Orchestrator virtual appliance boots successfully: Connect to the …
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…

630 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