Does Powershell ISE suppord aws cli? - amazon-web-services

I have configured AWS CLI on my Powershell and everything works fine but when I tried to run the same from Powershell ISE, It seemed that Powershell ISE did not recognize aws command at all.
It got me thinking, whether AWS CLI is supported on Powershell ISE? If it does, am I missing some configuration with environmental variables? If it doesn't, is there any particular reason behind it?

ISE notwithstanding...
Your need to import the AWS module to use it, just as you would any other PowerShell module that does not autoload for whatever reason.
As per the AWS PowerShell technical docs.
Setting up the AWS Tools for Windows PowerShell
https://docs.amazonaws.cn/powershell/latest/userguide/pstools-getting-set-up.html
To load the PowerShell Tools module into your current session
Open a PowerShell prompt and type the following command:
Import-Module "C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.psd1"
Note
In PowerShell 4.0 and later releases, Import-Module also searches the
Program Files folder for installed modules, so it is not necessary to
provide the full path to the module. You can run the following command
to import the AWSPowerShell module. In PowerShell 3.0 and later,
running a cmdlet in the module also automatically imports a module
into your session.
Import-Module AWSPowerShell
As per messing with AWS in my very customized ISE profile.
(Get-CimInstance -ClassName Win32_OperatingSystem).Caption
<#
# Results
Microsoft Windows 10 Pro
#>
$psISE
<#
CurrentPowerShellTab : Microsoft.PowerShell.Host.ISE.PowerShellTab
CurrentFile : Microsoft.PowerShell.Host.ISE.ISEFile
CurrentVisibleHorizontalTool :
CurrentVisibleVerticalTool : Microsoft.PowerShell.Host.ISE.ISEAddOnTool
Options : Microsoft.PowerShell.Host.ISE.ISEOptions
PowerShellTabs : {PowerShell 1}
#>
Import-Module -Name AWSPowerShell -Verbose
<#
# Results
VERBOSE: Loading module from path 'C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.psd1'.
VERBOSE: Loading 'Assembly' from path 'C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSSDK.ACMPCA.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSSDK.ACMPCA.dll'.
....
#>
Get-Module -Name '*aws*' |
Format-Table -AutoSize
<#
# Results
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 3.3.618.0 AWSPowerShell {Add-AASScalableTarget, Add-ACMCertificateTag, ...
#>
Get-Command -Name '*aws*' |
Format-Table -AutoSize
<#
# Results
CommandType Name Version Source
----------- ---- ------- ------
Alias Clear-AWSCredentials 4.0.5.0 AWS.Tools.Common
Alias Clear-AWSCredentials 4.0.0.0 AWS.Tools.Common
Alias Clear-AWSCredentials 3.3.618.0 AWSPowerShell
...
#>
Get-Command -Module AWSPowerShell |
Format-Table -AutoSize
<#
# Results
CommandType Name Version Source
----------- ---- ------- ------
Alias Add-ALXBContactWithAddressBook 3.3.618.0 AWSPowerShell
Alias Add-ASInstances 3.3.618.0 AWSPowerShell
Alias Add-CTTag 3.3.618.0 AWSPowerShell
#>
Get-Command -Module AWSPowerShell -CommandType Cmdlet |
Format-Table -AutoSize
<#
# Results
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Add-AASScalableTarget 3.3.618.0 AWSPowerShell
Cmdlet Add-ACMCertificateTag 3.3.618.0 AWSPowerShell
Cmdlet Add-ADSConfigurationItemsToApplication 3.3.618.0 AWSPowerShell
...
#>

Related

How can I install Oracle Database 18c XE into Windows docker container?

I'm not able to install Oracle Database 18c Express Edtition into a Windows docker container.
The Oracle silent setup (documented here) reports success, but no installation is being performed. The destination directory (C:\OracleXE\) is empty. And, of course, nothing is installed.
What am I doing wrong here?
This is my Dockerfile
# escape=`
FROM mcr.microsoft.com/windows:20H2
USER ContainerAdministrator
COPY / /O18c
WORKDIR /O18c
SHELL ["PowerShell", "-Command"]
RUN New-Item 'C:\db-data' -ItemType Directory; New-LocalUser -Name OracleAdministrator -NoPassword -UserMayNotChangePassword -AccountNeverExpires; Set-LocalUser -Name OracleAdministrator -PasswordNeverExpires:$True; $adm = (Get-LocalGroup | Where-Object {$_.Name.IndexOf('Admin') -eq 0}).Name; Add-LocalGroupMember -Group $adm -Member OracleAdministrator
USER OracleAdministrator
RUN ./Setup.exe /s /v"RSP_FILE=C:\O18c\XEInstall.rsp" /v"/L*v C:\O18c\setup.log" /v"/qn"
EXPOSE 1521 5550 3389
VOLUME C:\db-data
ENTRYPOINT PowerShell
This is my XEInstall.rsp file
#Do not leave any parameter with empty value
#Install Directory location, username can be replaced with current user
INSTALLDIR=C:\OracleXE\
#Database password, All users are set with this password, Remove the value once installation is complete
PASSWORD=foobar123!
#If listener port is set to 0, available port will be allocated starting from 1521 automatically
LISTENER_PORT=0
#If EM express port is set to 0, available port will be used starting from 5550 automatically
EMEXPRESS_PORT=0
#Specify char set of the database
CHAR_SET=AL32UTF8
This is my directory structure:
This is my docker build command:
docker build -f .\Dockerfile .\OracleXE184_Win64\
Apparently, the Oracle setup doesn't work with PowerShell.
When run with standard command prompt, setup installs fine.
This is my working Dockerfile
# escape=`
FROM mcr.microsoft.com/windows:20H2
USER ContainerAdministrator
COPY / /O18c
WORKDIR /O18c
RUN PowerShell -Command "New-Item 'C:\db-data' -ItemType Directory; New-LocalUser -Name OracleAdministrator -NoPassword -UserMayNotChangePassword -AccountNeverExpires; Set-LocalUser -Name OracleAdministrator -PasswordNeverExpires:$True; $adm = (Get-LocalGroup | Where-Object {$_.Name.IndexOf('Admin') -eq 0}).Name; Add-LocalGroupMember -Group $adm -Member OracleAdministrator;"
USER OracleAdministrator
RUN setup.exe /s /v"RSP_FILE=C:\O18c\XEInstall.rsp" /v"/L*v C:\O18c\setup.log" /v"/qn"
RUN PowerShell -Command "Get-ChildItem; Get-ChildItem \ -Attributes Directory;"
EXPOSE 1521 5550 3389
VOLUME C:\db-datado
ENTRYPOINT PowerShell

How to list all iso files of a particular datastore using powercli in VMware vSphere

I am trying to list all iso files in ISO directory of a particular datastore in VMware vSphere using powercli. I am able to list all the isos in all the datastores using the below command though but not able to do so for a particular datastore.
dir vmstores:\ -Recurse -Include *.iso | Select Name,FolderPath
I think you'll need to do something more like:
dir vmstore:\datacentername\datastorename -Recurse -Include *.iso | Select Name, FolderPath
I found that the below set of commands worked.
$datastoreName = 'enter_name_of_datastore'
$ds = Get-Datastore -Name $datastoreName
New-PSDrive -Location $ds -Name DS -PSProvider VimDatastore -Root '\' | Out-Null
Get-ChildItem -Path DS:\ISO -Include *.iso -Recurse | Select Name,FolderPath
Remove-PSDrive -Name DS -Confirm:$false

Problems building Qt Static 5.3.2

So I am trying to build Qt-Static 5.3.2. I am using a powershell script I downloaded to simplify the process but clearly it is not working. I am going to be tackling each error individually for the rest of the day. I am a beginner and I don't fully understand the build process so any bits of advice and insights is welcomed and appreciated.
I have posted the output on this dropbox link because it has 10X the characters that is allowed.
https://www.dropbox.com/s/poge94qm1wzg5vg/Building%20static%20Qt%20version%205.3.2.docx?dl=0
#-----------------------------------------------------------------------------
#
# Copyright (c) 2013, Thierry Lelegard
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
#
#-----------------------------------------------------------------------------
<#
.SYNOPSIS
Build a static version of Qt for Windows.
.DESCRIPTION
This scripts downloads Qt source code, compiles and installs a static version
of Qt. It assumes that a prebuilt Qt / MinGW environment is already installed,
typically in C:\Qt. This prebuilt environment uses shared libraries. It is
supposed to remain the main development environment for Qt. This script adds
a static version of the Qt libraries in order to allow the construction of
standalone and self-sufficient executable.
This script is typically run from the Windows Explorer.
Requirements:
- Windows PowerShell 3.0 or higher.
- 7-zip.
.PARAMETER QtSrcUrl
URL of the Qt source file archive.
By default, use the latest identified version.
.PARAMETER QtStaticDir
Root directory where the static versions of Qt are installed.
By default, use C:\Qt\Static.
.PARAMETER QtVersion
The Qt version. By default, this script tries to extract the version number
from the Qt source file name.
.PARAMETER MingwDir
Root directory of the MinGW prebuilt environment. By default, use the version
which was installed by the prebuilt Qt environment.
.PARAMETER NoPause
Do not wait for the user to press <enter> at end of execution. By default,
execute a "pause" instruction at the end of execution, which is useful
when the script was run from Windows Explorer.
#>
[CmdletBinding()]
param(
$QtSrcUrl = "http://download.qt.io/official_releases/qt/5.3/5.3.2/single/qt-everywhere-opensource-src-5.3.2.7z",
$QtStaticDir = "C:\Qt\Static",
$QtVersion = "5.3.2",
$MingwDir = "C:\Qt\Tools\mingw482_32",
[switch]$NoPause = $false
)
# PowerShell execution policy.
Set-StrictMode -Version 3
#-----------------------------------------------------------------------------
# Main code
#-----------------------------------------------------------------------------
function Main
{
# Check that 7zip is installed. We use it to expand the downloaded archive.
[void] (Get-7zip)
# Get Qt source file name from URL.
$QtSrcFileName = Split-Path -Leaf $QtSrcUrl
# If Qt version is not specified on the command line, try to extract the value.
if (-not $QtVersion) {
$QtVersion = $QtSrcFileName -replace "`.[^`.]*$",''
$QtVersion = $QtVersion -replace 'qt-',''
$QtVersion = $QtVersion -replace 'everywhere-',''
$QtVersion = $QtVersion -replace 'opensource-',''
$QtVersion = $QtVersion -replace 'src-',''
$QtVersion = $QtVersion -replace '-src',''
}
Write-Output "Building static Qt version $QtVersion"
# Qt installation directory.
$QtDir = "$QtStaticDir\$QtVersion"
# Get MinGW root directory, if not specified on the command line.
if (-not $MingwDir) {
# Search all instances of gcc.exe from C:\Qt prebuilt environment.
$GccList = #(Get-ChildItem -Path C:\Qt\*\Tools\mingw*\bin\gcc.exe | ForEach-Object FullName | Sort-Object)
if ($GccList.Length -eq 0) {
Exit-Script "MinGW environment not found, no Qt prebuilt version?"
}
$MingwDir = (Split-Path -Parent (Split-Path -Parent $GccList[$GccList.Length - 1]))
}
Write-Output "Using MinGW from $MingwDir"
# Build the directory tree where the static version of Qt will be installed.
Create-Directory $QtStaticDir\src
Create-Directory $QtDir
# Download the Qt source package if not yet done.
Download-File $QtSrcUrl $QtStaticDir\src\$QtSrcFileName
# Directory of expanded packages.
$QtSrcDir = "$QtStaticDir\src\$((Get-Item $QtStaticDir\src\$QtSrcFileName).BaseName)"
# Expand archives if not yet done
Expand-Archive $QtStaticDir\src\$QtSrcFileName $QtStaticDir\src $QtSrcDir
# Patch Qt's mkspecs for static build.
$File = "$QtSrcDir\qtbase\mkspecs\win32-g++\qmake.conf"
if (-not (Select-String -Quiet -SimpleMatch -CaseSensitive "# [QT-STATIC-PATCH]" $File)) {
Write-Output "Patching $File ..."
Copy-Item $File "$File.orig"
#"
# [QT-STATIC-PATCH]
QMAKE_LFLAGS += -static -static-libgcc -Wl,-enable-stdcall-fixup -Wl,-enable -auto-import -Wl,-enable-runtime-pseudo-reloc
QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads -Wl
QMAKE_CFLAGS_RELEASE -= -O2
QMAKE_CFLAGS_RELEASE += -Os -momit-leaf-frame-pointer
DEFINES += QT_STATIC_BUILD
"# | Out-File -Append $File -Encoding Ascii
}
# Set a clean path including MinGW.
$env:Path = "$MingwDir\bin;$MingwDir\opt\bin;$env:SystemRoot\system32;$env:SystemRoot"
# Force English locale to avoid weird effects of tools localization.
$env:LANG = "en"
# Set environment variable QT_INSTALL_PREFIX. Documentation says it should be
# used by configure as prefix but this does not seem to work. So, we will
# also specify -prefix option in configure.
$env:QT_INSTALL_PREFIX = $QtDir
# Configure, compile and install Qt.
Push-Location $QtSrcDir
cmd /c "configure.bat -static -release -platform win32-g++ -prefix $QtDir `
-qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -qt-sql-sqlite -no-openssl `
-opensource -confirm-license `
-make libs -nomake tools -nomake examples -nomake tests"
mingw32-make -k -j4
mingw32-make -k install
Pop-Location
# Patch Qt's installed mkspecs for static build of application.
$File = "$QtDir\mkspecs\win32-g++\qmake.conf"
#"
CONFIG += static
"# | Out-File -Append $File -Encoding Ascii
Exit-Script
}
#-----------------------------------------------------------------------------
# A function to exit this script. The Message parameter is used on error.
#-----------------------------------------------------------------------------
function Exit-Script ([string]$Message = "")
{
$Code = 0
if ($Message -ne "") {
Write-Output "ERROR: $Message"
$Code = 1
}
if (-not $NoPause) {
pause
}
exit $Code
}
#-----------------------------------------------------------------------------
# Silently create a directory.
#-----------------------------------------------------------------------------
function Create-Directory ([string]$Directory)
{
[void] (New-Item -Path $Directory -ItemType "directory" -Force)
}
#-----------------------------------------------------------------------------
# Download a file if not yet present.
# Warning: If file is present but incomplete, do not download it again.
#-----------------------------------------------------------------------------
function Download-File ([string]$Url, [string]$OutputFile)
{
$FileName = Split-Path $Url -Leaf
if (-not (Test-Path $OutputFile)) {
# Local file not present, start download.
Write-Output "Downloading $Url ..."
try {
$webclient = New-Object System.Net.WebClient
$webclient.DownloadFile($Url, $OutputFile)
}
catch {
# Display exception.
$_
# Delete partial file, if any.
if (Test-Path $OutputFile) {
Remove-Item -Force $OutputFile
}
# Abort
Exit-Script "Error downloading $FileName"
}
# Check that the file is present.
if (-not (Test-Path $OutputFile)) {
Exit-Script "Error downloading $FileName"
}
}
}
#-----------------------------------------------------------------------------
# Get path name of 7zip, abort if not found.
#-----------------------------------------------------------------------------
function Get-7zip
{
$Exe = "C:\Program Files\7-Zip\7z.exe"
if (-not (Test-Path $Exe)) {
$Exe = "C:\Program Files (x86)\7-Zip\7z.exe"
}
if (-not (Test-Path $Exe)) {
Exit-Script "7-zip not found, install it first, see http://www.7-zip.org/"
}
$Exe
}
#-----------------------------------------------------------------------------
# Expand an archive file if not yet done.
#-----------------------------------------------------------------------------
function Expand-Archive ([string]$ZipFile, [string]$OutDir, [string]$CheckFile)
{
# Check presence of expected expanded file or directory.
if (-not (Test-Path $CheckFile)) {
Write-Output "Expanding $ZipFile ..."
& (Get-7zip) x $ZipFile "-o$OutDir" | Select-String -Pattern "^Extracting " -CaseSensitive -NotMatch
if (-not (Test-Path $CheckFile)) {
Exit-Script "Error expanding $ZipFile, $OutDir\$CheckFile not found"
}
}
}
#-----------------------------------------------------------------------------
# Execute main code.
#-----------------------------------------------------------------------------
. Main

Backup List in Sharepoint 2010 in Shell

I want to backup a List of Sharepoint 2010 using the powershell.
I can backup the list using the central Administration and can also backup the whole Site using
Export-SPWeb -Identity http://siteurl:22222/en-us -Path \\public\backup.cmp
But when I try to export a specific List (with the path that is also shown using the Central Administration):
Export-SPWeb -Identity http://siteurl:22222/en-us/Lists/MyList -Path \\public\backup.cmp
I receive the error:
"The URL provided is invalid. Only valid URLs
that are site collections or sites are allowed to be exported using
stsadm.exe"
I also tried
Export-SPWeb -Identity http://siteurl:22222/en-us -Path \\public\backup.cmp -ItemURL http://siteurl:22222/en-us/Lists/MyList
getting the same error
Thanks in advance
Try to fiddle with the ItemUrl parameter value:
Export-SPWeb -Identity http://siteurl:22222/en-us -Path \\public\backup.cmp
-ItemUrl /Lists/MyList
or
Export-SPWeb -Identity http://siteurl:22222/en-us -Path \\public\backup.cmp
-ItemUrl /en-us/Lists/MyList
or
Export-SPWeb -Identity http://siteurl:22222/en-us -Path \\public\backup.cmp
-ItemUrl "/Lists/MyList"
Different sources show different syntax:
SharePoint 2010 Granular Backup-Restore Part 1
Failing to export with Export-SPWeb
If you have the following kind of setup:
Site Collection e.g. http://localhost:81
|
|-> Subsite 1 e.g. tools (http://localhost:81/tools)
|
|-> Subsite 2 e.g. admin (http://localhost:81/tools/admin)
I found the following worked for lists on the subsite:
Export-SPWeb -Identity http://<site>:<port>/<subsite1>/<subsite2> -ItemUrl /<subsite1>/<subsite2>/<listName> -Path <localpath>/<filename>.cmp -IncludeVersions All
e.g.
Export-SPWeb -Identity http://localhost:81/tools/admin/ -ItemUrl /tools/admin/RequestList -Path C:/Temp/Backup.cmp -IncludeVersions All
To ensure you've got the right url for your list, use the following command (thanks to HAZET here: http://social.technet.microsoft.com/Forums/en-US/sharepoint2010setup/thread/a1f48e70-9360-440f-b160-525fbf2b8412/):
$(Get-SPWeb -identity http://<site>:<port>/<subsite1>/<subsite2>).lists | ft title, #{Name="itemURL"; Expression = { $_.parentWebURL + "/" + $_.RootFolder}}
e.g.
$(Get-SPWeb -identity http://localhost:81/tools/admin/).lists | ft title, #{Name="itemURL"; Expression = { $_.parentWebURL + "/" + $_.RootFolder}}
Some examples of various errors I encountered whilst trying to get this to work:
The URL provided is invalid
Export-SPWeb : <nativehr>0x80070057</nativehr><nativestack></nativestack> At line:1 char:13
CategoryInfo : InvalidData: (Microsoft.Share...CmdletExportWeb: SPCmdletExportWeb) [Export-SPWeb], SPException FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletExportWeb
Some things to check:
Check that -Identity has the trailing slash i.e. http://localhost:81/
Check that you have the complete URL in Identity (if using subsites, include subsites)
Check that the path where you're trying to store your export file exists
Check that your ItemUrl is correct (i.e. starts with / and is a directory, not a specific file e.g. is /tools/admin/RequestsList, not /tools/admin/RequestsList/AllItems.aspx
Check that you have permissions to perform the export
Further info that might be helpful:
Identity: The URL of your SharePoint site
ItemUrl: The relative URL of your list/document library
Path: The target filename and location for the exported list e.g. C:/Temp/backup.cmp
IncludeVersion: What versions of the document you wish to export.
Export-SPWeb
http://technet.microsoft.com/en-us/library/ff607895.aspx
Export a site, list or document library in SharePoint 2010
http://technet.microsoft.com/en-us/library/ee428301.aspx
Import a list or document library in SharePoint 2010
http://technet.microsoft.com/en-us/library/ee428322.aspx

VisualSVN post-commit hook with batch file

I'm running VisualSVN on a Windows server.
I'm trying to add a post-commit hook to update our staging project whenever a commit happens.
In VisualSVN, if I type the command in the hook/post-commit dialog, everything works great.
However, if I make a batch file with the exact same command, I get an error that says the post-commit hook has failed. There is no additional information.
My command uses absolute paths.
I've tried putting the batch file in the VisualSVN/bin directory, I get the same error there.
I've made sure VisualSVN has permissions for the directories where the batch file is.
The only thing I can think of is I'm not calling it correctly from VisualSVN. I'm just replacing the svn update command in the hook/post-commit dialog with the batch file name ("c:\VisualSVN\bin\my-batch-file.bat") I've tried it with and without the path (without the path it doesn't find the file at all).
Do I need to use a different syntax in the SVNCommit dialog to call the batch file? What about within the batch file (It just has my svn update command. It works if I run the batch file from the command line.)
Ultimately I want to use a batch file because I want to do a few more things after the commit.
When using VisualSVN > Select the Repo > Properties > Hooks > Post-commit hook.
Where is the code I use for Sending an Email then running a script, which has commands I want to customize
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" ^
commit-notification "%1" -r %2 ^
--from support#domainname.com --to "support#domainname.com" ^
--smtp-server mail.domainname.com ^
--no-diffs ^
--detailed-subject
--no-html
set PWSH=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe
%PWSH% -command $input ^| C:\ServerScripts\SVNScripts\post-commit-wp.ps1 %1 %2
if errorlevel 1 exit %errorlevel%
The script file is located on C:\ServerScripts\SVNScripts\
post-commit-wp.ps1 and I pass in two VisualSVN variables as %1 and %2
%1 = serverpathwithrep
%2 = revision number
The script file is written in Windows PowerShell
# PATH TO SVN.EXE
$svn = "C:\Program Files\VisualSVN Server\bin\svn.exe"
$pathtowebistesWP = "c:\websites-wp\"
# STORE HOOK ARGUMENTS INTO FRIENDLY NAMES
$serverpathwithrep = $args[0]
$revision = $args[1]
# GET DIR NAME ONLY FROM REPO-PATH STRING
# EXAMPLE: C:\REPOSITORIES\DEVHOOKTEST
# RETURNS 'DEVHOOKTEST'
$dirname = ($serverpathwithrep -split '\\')[-1]
# Combine ServerPath with Dir name
$exportpath = -join($pathtowebistesWP, $dirname);
# BUILD URL TO REPOSITORY
$urepos = $serverpathwithrep -replace "\\", "/"
$url = "file:///$urepos/"
# --------------------------------
# SOME TESTING SCRIPTS
# --------------------------------
# STRING BUILDER PATH + DIRNAME
$name = -join($pathtowebistesWP, "testscript.txt");
# CREATE FILE ON SERVER
New-Item $name -ItemType file
# APPEND TEXT TO FILE
Add-Content $name $pathtowebistesWP
Add-Content $name $exportpath
# --------------------------------
# DO EXPORT REPOSITORY REVISION $REVISION TO THE ExportPath
&"$svn" export -r $revision --force "$url" $exportpath
I added comments to explain each line and what it does. In a nutshell, the scripts:
Gets all the parameters
Build a local dir path
Runs SVN export
Places files to a website/publish directory.
Its a simple way of Deploying your newly committed code to a website.
Did you try to execute batch file using 'call' command? I mean:
call C:\Script\myscript.bat
I was trying the same thing and found that you also must have the script in the hooks folder.. the bat file that is.