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
663 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
[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
  • 5
6 Comments
 
LVL 1

Accepted Solution

by:
robertodf earned 500 total points
ID: 35096888
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
ID: 35099358
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
ID: 35099674
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
Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

 

Author Comment

by:cawasaki
ID: 35099738
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
ID: 35107068
Up , any help plz?
0
 

Author Closing Comment

by:cawasaki
ID: 35123860
i accept your partial script.

Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

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