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
661 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
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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