Solved

powershell script to export a value of register keys and check if .exe file exist in specific folder

Posted on 2011-03-10
6
654 Views
Last Modified: 2012-05-11
Hi,

I need a script to do this for a txt file with the server name like this:

server1
server2
server3
.....

the script must check all this remotely:

1-Check if .exe file exist in this 2 folders and export the file name if it is .exe file
      -c:\test1\folder1
      -c:\test2\folder2

2-Export all keys and Data for this registry keys:
       -HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\table pc
        -HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\table pc

i need a result file with all this information.

Thanks if you can help me.
0
Comment
Question by:cawasaki
  • 5
6 Comments
 
LVL 1

Accepted Solution

by:
robertodf earned 500 total points
Comment Utility
Here goes the first part, the one that reads the file with the name of the servers and checks for file existence .

please test it in your environment.

Regards
foreach ($server in $(get-content .\servers.txt)){

	$files=get-childitem \\$server\C$\test1\folder1	

	foreach ($file in $files){

		if ($file.Extension -eq ".exe") {

		write $file.Name

		}

	}

	$files=get-childitem \\$server\C$\test2\folder2	

	foreach ($file in $files){

		if ($file.Extension -eq ".exe") {

		write $file.Name

		}

}

Open in new window

0
 

Author Comment

by:cawasaki
Comment Utility
ok i will test, and for the part 2:

2-Export all keys and Data for this registry keys:
       -HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\table pc
        -HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\table pc

???

thanks for your help
0
 

Author Comment

by:cawasaki
Comment Utility
ok first test:

[PS] C:\Temp\PLOP>.\plop.ps1
Missing closing '}' in statement block.
At C:\Temp\PLOP\plop.ps1:25 char:1
+ } <<<<

so i added the missed }


and it work but i have 0 result, not file nothing and i needalog to check it after i execute the script.

thanks
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:cawasaki
Comment Utility
oki have test and my constat:

1-if in one server in the list one folder not exist the script exit check

2- the result is just viewed in the screen,i need a result file where i can check the result like this:

server1:
file.exe, file2.exe....

server2:
file.exe, file2.exe....

server3:
file.exe, file2.exe....

Thanks
0
 

Author Comment

by:cawasaki
Comment Utility
Up , any help plz?
0
 

Author Closing Comment

by:cawasaki
Comment Utility
i accept your partial script.

Thanks
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 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

10 Experts available now in Live!

Get 1:1 Help Now