It’s fairly similar in Powershell. Rather than changing the context of the directory, you can also just pass the path to git. The semi-colons are line breaks and are just executed as separate commands in Powershell as well. Powershell uses cmdlets, but there are aliases so “dir” is really Get-ChildItem:
PS C:\> Get-Alias cd
CommandType Name Version Source
----------- ---- ------- ------
Alias cd -> Set-Location
PS C:\> Get-Alias dir
CommandType Name Version Source
----------- ---- ------- ------
Alias dir -> Get-ChildItem
Here is a basic code to execute a loop:
#Get folder childtren in path, Alias for dir
foreach ($path in (Get-ChildItem -Path C:\Scripts -Directory)) {
$path.FullName
#Change context to path, Alias for cd (Change Directory)
Set-Location -Path $path.FullName
}
Thanks a lot for the help. But I’m getting this error:
.\up.ps1 : The term '.\up.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ .\up.ps1
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (.\up.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Also, is there any way to bind git add -A ; git commit -m "Auto Git Commit" ; git push this code inside the script? So, it automatically execute the command when I execute the PowerShell script.