Quantcast
Channel: Powershell – Marc Valk dot Net
Browsing all 14 articles
Browse latest View live

PowerShell: Count Files in Folder and write to file

For my own backlog: $subfolders = Get-childitem <path to folder> -recurse | where {$_.psIsContainer} foreach ($subfolder in $subfolders) { $filecount = (dir $subfolder.fullname  | where...

View Article


PowerShell: Change Service startup mode

To change the startup mode of every disabled service to manual, you can use the following PowerShell Code: get-wmiobject win32_service | where-object {$_.StartMode -eq 'Disabled'} | ` foreach-object...

View Article


PowerShell: IP Address Details

It irritates me that when I execute the command “IPConfig” to get my current DHCP IP Address, I get a large list of all kind of adapters in which I am not interested. I then have to scroll up in the...

View Article

PowerShell: backup your SQL Agent Jobs

I needed to backup some SQL Agent Jobs. I decided to save them to a file, but I wanted to schedule this (in the event they might change). Below the PowerShell Script I used...

View Article

PowerShell: moving my photo’s up one folder

My photo directory existed in the following structure:<Drive>:<YEAR PHOTO WAS TAKEN><DAY OF PHOTO> I didn’t want that anymore, I just wanted the following structure:...

View Article


PowerShell: Moving files into subfolder based on date

A script to move files from one directory to another and ordering them in subdirectory in the destination folder. The subdirectory name is bases on the date of the file, thus ordering all files with...

View Article

Changing an Office 365 User Principal Name with Powershell

It is very ease to change your login name in Office 365 if you have PowerShell for office 365 (x86 version, x64 Version) installed. First connect to Office 365 Connect-msolService Enter your...

View Article

PowerShell: Import Scheduled Task

Some powershell I needed to import some scheduled tasks (xml files). Just for my own reference $XMLTaskDir = "C:\Program Files (x86)\****\***\" $Tasks = Get-ChildItem -Path $XMLTaskDir -Filter *.xml...

View Article


Running PowerShell Script from Netlogon Share

To run a powershell script from a netlogon share, proceed as follows: create a batch file on the Netlogon Share call your PowerShell Script:powershell -executionpolicy bypass -file...

View Article


Powershell: Set default printer based on IP address

Simple – quick and dirty’ Powershell script to change your default printer based on the location where you are (i.e. @home or @work)$NetworkAdapter = Get-WmiObject -Class...

View Article

PowerShell: compare 2 directory’s

Comparing two directory’s and listing the differences$dir1 = “\\server1\c$\folder1″ $dir2 = “\\server2\c$\folder1″ $d1 = get-childitem -path $dir1 -recurse $d2 = get-childitem -path $dir2 -recurse...

View Article

Powershell: copy files based on date

To copy files from a certain date to a different folder you can use the following PowerShell command: get-childitem | where-object {$_.creationtime -ge "7/29/2014" -and $_creationtime -le "29/7/2014"}...

View Article

Image may be NSFW.
Clik here to view.

PowerShell: Copying Latest Files to multiple servers

Problem: I have a source folders which consisted of multiple directory’s (builds from TFS). I wanted to copy the latest folder (Based on LastWriteTime) to several servers. Answer: use-powershell (what...

View Article


Exporting AD users with email

To export all active directory users and their email addresses  from a certain OU (ie. finance) to a comma seperated file, use the following PowerShell command Get-ADUser -filter * -SearchBase...

View Article
Browsing all 14 articles
Browse latest View live


Latest Images