Showing posts with label copy-item. Show all posts
Showing posts with label copy-item. Show all posts

Thursday, September 19, 2013

Change windows Login Screen using Powershell.


Hi,
We all love customization and personalize our laptop setting. Like we all (majority of) love to change our wallpapers.
windows-7-logon-background
I have few scripts, which rebooted a laptop twice thrice, on those scripts i use Logon screen as a information and “how to’s” board.
backgroundDefault
and if you want some fun , you can also change the login screen with your choice of picture.
How to change login screen?
  1. Make sure the picture which you want to set as Login Screen is less then 254KB
  2. Rename the picture to “backgroundDefault.jpg
  3. A2
Run Powershell as Administrator.

Now, we need to set “OemBackgroud” value to 1 in the registry

Set-ItemProperty -Path hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background 
 -Name OEMBackground -Value 1
 
A1

Now copy the “backgroundDefault.jpg”  to the "C:\Windows\System32\oobe\info\backgrounds\" folder.

Copy-Item -Force "c:\myscripts\backgroundDefault.jpg" 
 "C:\Windows\System32\oobe\info\backgrounds\" -Verbose

A3

Now, to test, lock you screen (Windows Key + L ) and see if logon screen is changed or not.

But mine is changed :)

IMG-20130919-00495




How to set login screen to default again?

To set logon screen to default again, set the OEM key to “0” again.

Set-ItemProperty -Path 
hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background  
-Name OEMBackground -Value 0

I hope that you find is useful.

Aman Dhally

clip_image001 clip_image002 clip_image003 clip_image005clip_image007

Friday, November 18, 2011

Copy Files and Folders using PowerShell

 

 

Hi,

Copy files and folders this is the task which every Admin or even a end user performs daily.

How we can Copy files and folder using PowerShell?

Quite Easy, we just need to use Copy-Item cmdlet with few Switch Parameters that all.

Cmdlet used : Copy-Item

:::: Copy Files

Lets create a a new folder to Backup files currently I have  one Folder named “Folder_A” which contain Data and we will create a new folder named as “Backup_A” , and then copy data from “Folder_A” to “backup_A”

Files-1

let create a new folder named “Backup_A”

Files-2

Now we have two folders “Folder A” and “Backup_A”

Files-3

now copy a file from “Folder_A” to “backup_A” ,

command is: Copy-Item D:\Demo\Folder_A\Book.txt -Destination D:\Demo\Backup_A

file successfully copied.

Files-4

:::: Copy Txt file only

-Include

if we want to copy specific type of files only then we can use –Include switch Parameter followed by the type .

-Verbose 

We can use –Verbose switch to see which files are getting copied

command: Copy-Item D:\Demo\Folder_A\* -Destination D:\Demo\Backup_A -Include *.txt –Verbose

see the screenshot, command copied the .Txt files only

Files-5

:::: Exclude files to copying

-Exclude

If we are using Copy-Item cmdlet in a backup script it would be good we don’t backup Music,Video files on server. As a Ideal Policy we should not fill our SAN, Server storage with the backup of users music and videos.

to exclude these files to be copied use –Exclude switch parameter followed by file types example *.mp3,*.mp4 etc

in my Folder_A i have few MP3 audio and few MP4 video files, lets stop them copying to our Backup_A folder.

Files-6

note: * means all

Command: Copy-Item D:\Demo\Folder_A\* -Destination D:\Demo\Backup_A -Exclude *.mp3,*.mp4

When i search for *mp3 and  *mp4 no result were found and you can also see there is not a single MP3 and MP4 in “Backup_A” folder.

Files-7

:::: Copy Folders

the command is same like copying file but rather then specify file we need to specify folder

Command : Copy-Item D:\Demo\Folder_A\Recurse_Testing -Destination D:\Demo\Backup_A\

Folder Copied

Files-8

BUTTTTTTTT !!! wait…!!!!!!!!!!!!!

Check the folder again, Recurse_Testing have some Sub-folders which are not copied in backup_A

Files-9

-Recurse

to Copy All folder including sub-folders use –Recurse while copying

Command is:

Copy-Item -Recurse D:\Demo\Folder_A\Recurse_Testing -Destination D:\Demo\Backup_A\  -Verbose

Files-10

let check if it copied subfolder also.

Seems Identical isn’t.

Files-11

:::: Copy all files and Folders

To copy all file and folder we use * wildcard which means all , and –Recurse to copy sub-directories also and we also use –force do that if there any file exists with same name on backup folder it should get overwrites.

command : Copy-Item -Recurse D:\Demo\Folder_A\* -Destination D:\Demo\Backup_A -Force –Verbose

Files-12

lets check if these two folders are identical.

Seems like TWINS isn't ;-)

Files-13

Hope it is useful to someone .

Thanks

Aman Dhally