<# .SYNOPSIS Creates a zip file from a folder structure and uploads it to an FTP site. .DESCRIPTION Creates a zip file of all the scripts in the script library, then uses system.net.webrequest to uploade it to a web site. Uses ICSharpCode.SharpZipLib.dll See http://www.icsharpcode.net/OpenSource/SharpZipLib/ .NOTES File Name : zip-pshscripts.PS1 Author : Thomas Lee - tfl@psp.co.uk Requires : PowerShell V2 NB:The credentials shown here do not work (well they shouldn't) .LINK http://pshscripts.blogspot.com .EXAMPLE Assuming credentials were correct, an example would be PS C:\foo> zip-pshscripts.PS1 Directory: C:\foo Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 12/29/2008 11:34 AM 68722 PSScriptLib.ZIP Upload Stats: 226-Maximum disk quota limited to 100000 Kbytes Used disk quota 63140 Kbytes, available 36859 Kbytes 226 Transfer complete. #> ## # Start of script ## # First, load the zip library [void] [System.Reflection.Assembly]::LoadFrom("C:\foo\bin\ICSharpCode.SharpZipLib.dll") # Now create a new zip file object $zip = new-object ICSharpCode.SharpZipLib.Zip.FastZip # Define what to zip and from where $zipfile = "C:\foo\PSScriptLib.ZIP" $zipfrom = "E:\PowerShellScriptLib" $recurse = "true" $ziptoadd = ".ps1" # Now create the zip file $zip.CreateZip($zipfile, $zipfrom, $recurse, $ziptoadd) ls $zipfile # Here upload it $sendto = "ftp://www.reskit.net/powershell/scriptlib.zip" $ftprequest = [system.net.ftpwebrequest]::Create($Sendto) $ftprequest.Method = "STOR" # Now get the zip file and store it into $fileconents $file = Get-Content $zipfile $enc = [system.text.encoding]::default [byte[]] $filebyte= $enc.getbytes($file) # Set the length of the file to be sent $length = (ls $zipfile).length $ftprequest.ContentLength = $length # Now upload the file # Let's assume the ftp server is anonomyous (it's not of course!). $ftprequest.Credentials = New-Object system.Net.NetworkCredential "anonymous","tfl@psp.co.uk" $requestStream = $ftprequest.GetRequestStream() $requestStream.Write($filebyte, 0, $length) # Close file and get response $requestStream.Close() $response = $ftprequest.GetResponse(); # Display stats "Upload Stats:" $response.StatusDescription # Close response $response.Close();
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Showing posts with label ISE. Show all posts
Showing posts with label ISE. Show all posts
Tuesday, 1 July 2014
Zip-Pshscripts.ps1
Thursday, 23 December 2010
Set-IseThemeVim.ps1
- <#
- .SYNOPSIS
- This script sets an ISE Theme to similar to the old VIM editor.
- .DESCRIPTION
- This script sets the key values in $PsIse.Options to values consistent
- with the VIM editor, beloved by many, particularly on the Powershell
- product team. This script is based on Davis Mohundro's blog post
- (http://bit.ly/iib5IM), updated for RTM of PowerShell V2.0. See also
- .NOTES
- File Name : Set-ISEThemeVIM.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0 (ISE only)
- .LINK
- This script posted to:
- http://pshscriptsbog.blogspot.com
- http://bit.ly/iaA2iX
- .EXAMPLE
- This script when run resets colours on key panes, including
- colourising tokens in the script pane. Try it and see it...
- #>
- # PowerShell ISE version of the VIM blackboard theme at
- # http://www.vim.org/scripts/script.php?script_id=2280
- # Set font name and size
- $psISE.Options.FontName = 'Courier New'
- $psISE.Options.FontSize = 16
- # Set colours for output pane
- $psISE.Options.OutputPaneBackgroundColor = '#FF000000'
- $psISE.Options.OutputPaneTextBackgroundColor = '#FF000000'
- $psISE.Options.OutputPaneForegroundColor = '#FFFFFFFF'
- # Set colours for command pane
- $psISE.Options.CommandPaneBackgroundColor = '#FF000000'
- # Set colours for script pane
- $psise.options.ScriptPaneBackgroundColor ='#FF000000'
- # Set colours for tokens in Script Pane
- $psISE.Options.TokenColors['Command'] = '#FFFFFF60'
- $psISE.Options.TokenColors['Unknown'] = '#FFFFFFFF'
- $psISE.Options.TokenColors['Member'] = '#FFFFFFFF'
- $psISE.Options.TokenColors['Position'] = '#FFFFFFFF'
- $psISE.Options.TokenColors['GroupEnd'] = '#FFFFFFFF'
- $psISE.Options.TokenColors['GroupStart'] = '#FFFFFFFF'
- $psISE.Options.TokenColors['LineContinuation'] = '#FFFFFFFF'
- $psISE.Options.TokenColors['NewLine'] = '#FFFFFFFF'
- $psISE.Options.TokenColors['StatementSeparator'] = '#FFFFFFFF'
- $psISE.Options.TokenColors['Comment'] = '#FFAEAEAE'
- $psISE.Options.TokenColors['String'] = '#FF00D42D'
- $psISE.Options.TokenColors['Keyword'] = '#FFFFDE00'
- $psISE.Options.TokenColors['Attribute'] = '#FF84A7C1'
- $psISE.Options.TokenColors['Type'] = '#FF84A7C1'
- $psISE.Options.TokenColors['Variable'] = '#FF00D42D'
- $psISE.Options.TokenColors['CommandParameter'] = '#FFFFDE00'
- $psISE.Options.TokenColors['CommandArgument'] = '#FFFFFFFF'
- $psISE.Options.TokenColors['Number'] = '#FF98FE1E'
Labels:
ISE,
Powershell ISE,
PowerShell V2
Set-ISEThemeDefault.ps1
- <#
- .SYNOPSIS
- This script resets the ISE to default ‘theme’.
- .DESCRIPTION
- This script sets the key values in $PsIse.Options to their default
- options in $Psise.Options.DefaultOptions. This script is useful if you
- are playing with ISE options and don't quite get it right - just run this
- script to set things back to default.
- .NOTES
- File Name : Set-ISEThemeDefault.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0 (ISE only)
- .LINK
- This script posted to:
- http://bit.ly/gJpu2W
- .EXAMPLE
- This script when run just resets the theme to the default. To view, run from
- the ISE after changing options!
- #>
- # Set Basic options
- $psise.options.SelectedScriptPaneState = $psise.options.DefaultOptions.SelectedScriptPaneState
- $psise.options.ShowToolBar = $psise.options.DefaultOptions.ShowToolBar
- $psise.options.FontSize = $psise.options.DefaultOptions.FontSize
- $psise.options.Fontname = $psise.options.DefaultOptions.Fontname
- # set colouring
- $psise.options.ErrorForegroundColor = $psise.options.DefaultOptions.ErrorForegroundColor
- $psise.options.ErrorBackgroundColor = $psise.options.DefaultOptions.ErrorBackgroundColor
- $psise.options.WarningForegroundColor = $psise.options.DefaultOptions.WarningForegroundColor
- $psise.options.WarningBackgroundColor = $psise.options.DefaultOptions.WarningBackgroundColor
- $psise.options.VerboseForegroundColor = $psise.options.DefaultOptions.VerboseForegroundColor
- $psise.options.VerboseBackgroundColor = $psise.options.DefaultOptions.VerboseBackgroundColor
- $psise.options.DebugBackgroundColor = $psise.options.DefaultOptions.DebugBackgroundColor
- $psise.options.DebugForegroundColor = $psise.options.DefaultOptions.DebugForegroundColor
- $psise.options.OutputPaneBackgroundColor = $psise.options.DefaultOptions.OutputPaneBackgroundColor
- $psise.options.OutputPaneTextBackgroundColor = $psise.options.DefaultOptions.OutputPaneTextBackgroundColor
- $psise.options.OutputPaneForegroundColor = $psise.options.DefaultOptions.OutPutPaneForegroundColor
- $psise.options.CommandPaneBackgroundColor = $psise.options.DefaultOptions.CommandPaneBackgroundColor
- $psise.options.ScriptPaneBackgroundColor = $psise.options.DefaultOptions.ScriptPaneBackgroundColor
- $psise.options.ScriptPaneForegroundColor = $psise.options.DefaultOptions.ScriptPaneForegroundColor
- # More options
- $psise.options.ShowWarningForDuplicateFiles = $psise.options.DefaultOptions.ShowWarningForDuplicateFiles
- $psise.options.ShowWarningBeforeSavingOnRun = $psise.options.DefaultOptions.ShowWarningBeforeSavingOnRun
- $psise.options.UseLocalHelp = $psise.options.DefaultOpitons.UseLocalHelp
- $psise.options.CommandPaneUp = $psise.options.DefaultOptions.CommandPaneUp
- # Reset Tokens Colors
- $psISE.Options.TokenColors['Attribute'] = $psISE.Options.DefaultOptions.TokenColors['Attribute']
- $psISE.Options.TokenColors['Command'] = $psISE.Options.DefaultOptions.TokenColors['Command']
- $psISE.Options.TokenColors['CommandArgument'] = $psISE.Options.DefaultOPtions.TokenColors['CommandArgument']
- $psISE.Options.TokenColors['CommandParameter'] = $psISE.Options.DefaultOptions.TokenColors['CommandParameter']
- $psISE.Options.TokenColors['Comment'] = $psISE.Options.DefaultOptions.TokenColors['Comment']
- $psISE.Options.TokenColors['GroupEnd'] = $psISE.Options.DefaultOptions.TokenColors['GroupEnd']
- $psISE.Options.TokenColors['GroupStart'] = $psISE.Options.DefaultOptions.TokenColors['GroupStart']
- $psISE.Options.TokenColors['Keyword'] = $psISE.Options.DefaultOptions.TokenColors['Keyword']
- $psISE.Options.TokenColors['LineContinuation'] = $psISE.Options.DefaultOptions.TokenColors['LineContinuation']
- $psISE.Options.TokenColors['LoopLabel'] = $psISE.Options.DefaultOptions.TokenColors['LoopLabel']
- $psISE.Options.TokenColors['Member'] = $psISE.Options.DefaultOptions.TokenColors['Member']
- $psISE.Options.TokenColors['NewLine'] = $psISE.Options.DefaultOptions.TokenColors['NewLine']
- $psISE.Options.TokenColors['Number'] = $psISE.Options.DefaultOPtions.TokenColors['Number']
- $psISE.Options.TokenColors['Position'] = $psISE.Options.DefaultOptions.TokenColors['Position']
- $psISE.Options.TokenColors['StatementSeparator'] = $psISE.Options.DefaultOptions.TokenColors['StatementSeparator']
- $psISE.Options.TokenColors['String'] = $psISE.Options.DefaultOptions.TokenColors['String']
- $psISE.Options.TokenColors['Type'] = $psISE.Options.DefaultOptions.TokenColors['Type']
- $psISE.Options.TokenColors['Unknown'] = $psISE.Options.DefaultOptions.TokenColors['Unknown']
- $psISE.Options.TokenColors['Variable'] = $psISE.Options.DefaultOptions.TokenColors['Variable']
- # Done
Labels:
ISE,
Powershell ISE,
PowerShell V2
Subscribe to:
Posts (Atom)