Created
June 15, 2016 23:16
-
-
Save dajo/baaa606e82e64f2588610d77b0cf9243 to your computer and use it in GitHub Desktop.
creates a BMP image of Computer Name with random background color, for use with bginfo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inspired by Al Resch's use of bginfo to brand server desktops | |
Add-Type -AssemblyName System.Drawing | |
# set variables | |
$computername = $env:computername | |
$imageFormat = “System.Drawing.Imaging.ImageFormat” -as [type] | |
$filename = "wallpaper.bmp" | |
# which color will it be? | |
$selectedColor = ( ($color_array = "AliceBlue", "AntiqueWhite", "Aqua", "Aquamarine", "Azure", "Beige", "Bisque", "Black", "BlanchedAlmond", "Blue", "BlueViolet", "Brown", "BurlyWood", "CadetBlue", "Chartreuse", "Chocolate", "Coral", "CornflowerBlue", "Cornsilk", "Crimson", "Cyan", "DarkBlue", "DarkCyan", "DarkGoldenrod", "DarkGray", "DarkGreen", "DarkKhaki", "DarkMagenta", "DarkOliveGreen", "DarkOrange", "DarkOrchid", "DarkRed", "DarkSalmon", "DarkSeaGreen", "DarkSlateBlue", "DarkSlateGray", "DarkTurquoise", "DarkViolet", "DeepPink", "DeepSkyBlue", "DimGray", "DodgerBlue", "Firebrick", "FloralWhite", "ForestGreen", "Fuchsia", "Gainsboro", "GhostWhite", "Gold", "Goldenrod", "Gray", "Green", "GreenYellow", "Honeydew", "HotPink", "IndianRed", "Indigo", "Ivory", "Khaki", "Lavender", "LavenderBlush", "LawnGreen", "LemonChiffon", "LightBlue", "LightCoral", "LightCyan", "LightGoldenrodYellow", "LightGray", "LightGreen", "LightPink", "LightSalmon", "LightSeaGreen", "LightSkyBlue", "LightSlateGray", "LightSteelBlue", "LightYellow", "Lime", "LimeGreen", "Linen", "Magenta", "Maroon", "MediumAquamarine", "MediumBlue", "MediumOrchid", "MediumPurple", "MediumSeaGreen", "MediumSlateBlue", "MediumSpringGreen", "MediumTurquoise", "MediumVioletRed", "MidnightBlue", "MintCream", "MistyRose", "Moccasin", "NavajoWhite", "Navy", "OldLace", "Olive", "OliveDrab", "Orange", "OrangeRed", "Orchid", "PaleGoldenrod", "PaleGreen", "PaleTurquoise", "PaleVioletRed", "PapayaWhip", "PeachPuff", "Peru", "Pink", "Plum", "PowderBlue", "Purple", "Red", "RosyBrown", "RoyalBlue", "SaddleBrown", "Salmon", "SandyBrown", "SeaGreen", "SeaShell", "Sienna", "Silver", "SkyBlue", "SlateBlue", "SlateGray", "Snow", "SpringGreen", "SteelBlue", "Tan", "Teal", "Thistle", "Tomato", "Transparent", "Turquoise", "Violet", "Wheat", "White", "WhiteSmoke", "Yellow", "YellowGreen") | Get-Random ) | |
# getting my drawing tools ready | |
$bmp = new-object System.Drawing.Bitmap 1152,648 | |
$font = new-object System.Drawing.Font ("Consolas",80.0, [System.Drawing.FontStyle]::Bold) | |
$brushBg = [System.Drawing.Brushes]::$selectedColor | |
$brushFg = [System.Drawing.Brushes]::Black | |
$graphics = [System.Drawing.Graphics]::FromImage($bmp) | |
$graphics.FillRectangle($brushBg,0,0,$bmp.Width,$bmp.Height) | |
$graphics.SmoothingMode = "AntiAlias" | |
$graphics.PixelOffsetMode = "HighQuality" | |
$graphics.InterpolationMode = "HighQualityBicubic" | |
# draw and save | |
$graphics.DrawString($computername,$font,$brushFg,30,70) | |
$graphics.Dispose() | |
$bmp.Save($filename, $imageFormat::bmp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment