Posts Tagged ‘file’

PowerShell: How to delete a file based on a list of computers?

Sunday, January 31st, 2010

image[1]The following PowerShell script recipe will help you delete a remote file based on a list of computers stored in a text file. New PowerShell function will be created during the session which will be piped from the text file.

 

 

 

Generate C:\Scripts\Active_Computers.txt with computer names.

[PowerShell]
function delete-remotefile {
    PROCESS {
                $file = "\\$_\c$\install.exe"
                if (test-path $file)
                {
                echo "$_ install.exe exists"
                Remove-Item $file -force
                echo "$_ install.exe file deleted"
                }
            }
}

Get-Content  C:\Scripts\Active_Computers.txt | delete-remotefile
[/PowerShell]

PowerShell: How to check list of computers for a specific remote file ?

Sunday, January 31st, 2010

image The following PowerShell script recipe will help you check a remote file based on a list of computers stored in a text file. A new PowerShell function will be created during the session which will be piped from the text file.

In the following PowerShell example I will check if install.exe exists on the remote systems and echo the computername if the file is there.

 

Create new text file named C:\Scripts\Active_Computers.txt and populate the file with computer names.

[PowerShell]

function check-remotefile {

    PROCESS {

                $file = "\\$_\c$\install.exe"

                if (test-path $file)

                {

                echo "$_ file install.exe exists"

                }

            }

}

Get-Content  C:\Scripts\Active_Computers.txt | check-remotefile

[PowerShell]

File server: Windows Server 2003 Access-based Enumeration

Wednesday, March 25th, 2009

windows server 2003If you are managing a Windows Server 2003 file server than this add-on should be installed.

Windows Server 2003 Access-based Enumeration makes visible only those files or folders that the user has the rights to access. When Access-based Enumeration is enabled, Windows will not display files or folders that the user does not have the rights to access. This download provides a GUI and a CLI that enables this feature.

This is the first time I installed and used this tool myself. Easy to install and no reboot is required of the file server. It cleans the users view and we as system administrators have fewer “security audits” in our event viewers.

Access-based Enumeration

Click here to download the MSI setup files.

VMware ESX: SSH remote management

Friday, September 12th, 2008

After installing VMWare ESX 3.5 hypervisor host server I would like to manage this system with SSH remotely. Server is manufactured by Dell and the DRAC mgmt card interface is available but I prefer to use SSH. SSH is enabled by default but disallows access for root.

See my work log and screenshots how to enable this feature:

  • Login with root from the console
  • Change directory with “cd /etc/ssh”
  • Open sshd_config with “vi sshd_config”

image

  • Locate Authentication section and change “PermitRootLogin no” to “PermitRootLogin yes”; for going into edit mode type i; press ESC to exit

image

  • Type “:wq!” to save and exit the file
  • Restart the SSH deamon with “service sshd restart”

image

  • Start putty.exe or any of you favorite SSH remote management tools to connect to your ESX 3.5 server.

image

This procedure also applies to version 3.x. With this procedure I achieved to manage my ESX server remotely so I don’t need to use my remote management access card. SSH daemon also support secure file copy protocol which can be used to connect with WinSCP and download or upload any file/virtual machine to your VMFS file system.

image

Please be aware of any security implications! I enabled this kind of access because the management interface is sitting in a different VLAN than the vSwitch networks within virtual machine which are trunked amongst different networks.

Mount Linux file system on Windows operating systems

Sunday, August 3rd, 2008

Since I am dual booting between Ubuntu and Windows Vista on my desktop workstation I am missing my linux volumes on Vista. I have three large 500GB SATA2 disks and one of them is partitioned and formatted with Ext2 linux file system. I have two options to read my linux volumes from windows:

a) Explore2fs which is a simple tool and I don’t need to install any low level system drivers. Explore2fs only operates in Read-Only mode.
b) Ext2IFS which is a pure kernel mode file system driver Ext2fs.sys, which actually extends the Windows NT/2000/XP/Vista (x86/x64) operating system to include the Ext2 file system.

I want to have full read-write mode on my linux volumes and I installed option b.

image 
image

Drive L:\ is now mounted in READ/Write mode from my Windows Vista SP1 x64 operating system.

image

File Server: windows share migration

Wednesday, June 11th, 2008

You have a Windows File Server and you want to migrate the windows shares. What options do you have to complete this job? A) recreate them or B) migrate them from ServerA to ServerB. Sometimes option A is the only one you have but in most cases you want to keep those Windows Shares available as they were before and using some kind of script would be nice. Microsoft published a KB125996 article based on following procedures and my option B:

  • Reinstall Windows over an existing installation (a clean install, not an upgrade).
  • Move all of your data drives from one server to another.
  • Install Windows to another folder or drive on a computer that already has Windows installed.

I am performing a clean installation of a application server which has several file shares associated for application functionality. I don’t want to recreate them manually and I am using the next steps to complete this task.

a) Verify the shares you want to migrate and the drive letter location is the same on both servers.

image

b) Export the Shares key from HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares

reg export HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares LanmanServer.reg

image

c) Make sure the user and group still exist in the domain! When migrating from DomainA to Domain B make sure you recreate all users and groups. Copy LanmanServer.reg to ServerB and import the registry file.

reg import LanmanServer.reg
net stop server & net start server

image

Reboot the file server and verify the share with “net share” command; also check the System Eventlog for any warnings or errors.