Last active
October 16, 2017 15:04
-
-
Save lipkau/a7e3051dc264996a6d802d0e658236c1 to your computer and use it in GitHub Desktop.
Create new folder and naviagte into it #powershell #helperFunction #workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-Folder | |
{ | |
<# | |
.Synopsis | |
Create a new folder and navigate into it | |
.Description | |
Create a new folder and navigate into it | |
.Notes | |
Author : Oliver Lipkau <oliver@lipkau.net> | |
Source : https://gist.github.com/lipkau/a7e3051dc264996a6d802d0e658236c1 | |
.Inputs | |
System.String | |
.Parameter Path | |
Specifies the path of the folder to be created. | |
Path can be FQDN, UNC, Absolute or Relative. | |
.Example | |
New-Folder "C:\temp\myNewFolder" | |
----------- | |
Description | |
Create the folder with the path specifies and Set-Location (alias: 'cd') to that path | |
#> | |
[CmdletBinding()] | |
[OutputType()] | |
param( | |
[ValidateNotNullOrEmpty()] | |
[ValidateScript({(Test-Path $_ -IsValid)})] | |
[Parameter(ValueFromPipeline=$True,Mandatory=$True)] | |
[string]$Path | |
) | |
Process { | |
New-Object PSObject -Property @{path=$Path} | | |
New-Item -ItemType Directory | | |
Set-Location | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment