diff --git a/Install.ps1 b/Install.ps1 index 52d1bf9..2f1ba81 100644 --- a/Install.ps1 +++ b/Install.ps1 @@ -1,12 +1,11 @@ - # Setup variables - $GitURI = "https://git.wnd.sh/n/PSGraylog/archive/main.zip" - # Defaults to the first module path, however you can change this to any path you wish (provided it's in your $PSModulePath) - $OutputPath = "$($env:PSModulePath.Split(";")[0])/PSGraylog" - Invoke-WebRequest $GitURI -OutFile "$OutputPath.zip" - Expand-Archive "$OutputPath.zip" $OutputPath - # The archive nests the files, so we need to move the up a level - Move-Item "$OutputPath/PSGraylog/*" $OutputPath - # Remove the excess PSGraylog directory (it's empty) - Remove-Item "$OutputPath/PSGraylog" - # Remove the archive - Remove-Item "$OutputPath.zip" \ No newline at end of file +# Defaults to the first module path, however you can change this to any path you wish (provided it's in your $PSModulePath) +$ModulePath = $env:PSModulePath.Split(";")[0] +if (-NOT (Test-Path $ModulePath)) { New-Item -Path $ModulePath -ItemType Directory } # Create the module path if it doesn't exist (might happen on brand new installs) +$GitURI = "https://git.wnd.sh/n/PSGraylog/archive/main.zip" +$OutputPath = "$ModulePath/PSGraylog" + +Invoke-WebRequest $GitURI -OutFile "$OutputPath.zip" # Download the zip archive to the module path +Expand-Archive "$OutputPath.zip" $OutputPath # Extract the zip archive to the module path +Move-Item "$OutputPath/PSGraylog/*" $OutputPath # The archive nests the files, so we need to move the up a level +Remove-Item "$OutputPath/PSGraylog" # Remove the excess PSGraylog directory (it's empty) +Remove-Item "$OutputPath.zip" # Remove the archive \ No newline at end of file