Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
80 lines (65 sloc) 5.71 KB
# Copyright 2011 Splunk, Inc.
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# install script for Splunk PowerShell Resource Kit
# the path to a folder into which to install the Splunk PowerShell module. defaults to the user-specific module path for the current user. the folder is created if it does not already exist.
$modulePath = ( $env:psmodulepath -split ';' | select -first 1 ),
# specify to overwrite any existing Splunk module in the specified module path
if( ( test-path "$modulePath/Splunk" ) )
if( $force )
write-verbose "removing existing Splunk module from '$modulePath'";
ri "$modulePath/Splunk" -recurse -force;
write-error "Unable to copy module - a Splunk module is already installed at '$modulePath'. Specify the -force parameter to overwite an existing Splunk module.";
if( -not( Test-Path $modulePath ) )
Write-Verbose "creating module folder at '$modulePath'";
mkdir $modulePath | out-null;
# copy the Splunk folder from the Source hive to the specified Module hive
write-verbose "copying Splunk module from '$pwd' to '$modulePath'";
cp ./Source/Splunk -force:$force -rec -container -dest $modulePath;
Installs the Splunk PowerShell module into the PowerShell module path.
Installs the Splunk PowerShell module into the PowerShell module path. By default, the module is installed to the module hive for the current user.
This script does not accept pipeline input.
This script does not produce pipeline output.
C:\PS> ./install.ps1
Installs the Splunk module into the default location (the user-based module location for the current user). This command will produce an error if a Splunk module is already present. To bypass this error, specify the -force parameter.
C:\PS> ./install.ps1 -modulePath 'c:\modules' -force
Installs the splunk module into the custom module location 'C:\Modules'. Any Splunk module existing in the custom location is overwritten without warning.
Note that installing to a custom location is not common; please consult the PowerShell documentation topic about_modules before considering such an action.
Something went wrong with that request. Please try again.