Ok, as a newbie to Powerhsell it still amazes me how clever it is, whilst i was writing my recent report script which takes the results of various commands and outputs them to a word document for a report I was stuck with the properties of one of the objects.
I had been trying to translate some of the documented vbscript’s from the msdn site and use the same features as there wasnt much documentation for doing this in powershell at the moment on the web, I really got stuck finding the properties so i experimeted with get-member, check this out…
$msWord = New-Object -Com Word.Application
Which creates a new word com object
$msword | get-member
Didnt expect this to do anything as how would powershell know the properties of a com object but wait, look what i recieved….
TypeName: System.__ComObject#{00020970-0000-0000-c000-000000000046} | ||
Name | MemberType | Definition |
—- | ———- | ———- |
Activate | Method | void Activate () |
AddAddress | Method | void AddAddress (SAFEARRAY(st… |
AutomaticChange | Method | void AutomaticChange () |
BuildKeyCode | Method | int BuildKeyCode (WdKey, Vari… |
CentimetersToPoints | Method | float CentimetersToPoints (fl… |
ChangeFileOpenDirectory | Method | void ChangeFileOpenDirectory … |
CheckGrammar | Method | bool CheckGrammar (string) |
CheckSpelling | Method | bool CheckSpelling (string, V… |
CleanString | Method | string CleanString (string) |
DDEExecute | Method | void DDEExecute (int, string) |
DDEInitiate | Method | int DDEInitiate (string, string) |
DDEPoke | Method | void DDEPoke (int, string, st… |
DDERequest | Method | string DDERequest (int, string) |
DDETerminate | Method | void DDETerminate (int) |
DDETerminateAll | Method | void DDETerminateAll () |
DefaultWebOptions | Method | DefaultWebOptions DefaultWebO… |
DiscussionSupport | Method | void DiscussionSupport (Varia… |
GetAddress | Method | string GetAddress (Variant, V… |
GetDefaultTheme | Method | string GetDefaultTheme (WdDoc… |
GetSpellingSuggestions | Method | SpellingSuggestions GetSpelli… |
GoBack | Method | void GoBack () |
GoForward | Method | void GoForward () |
Help | Method | void Help (Variant) |
HelpTool | Method | void HelpTool () |
InchesToPoints | Method | float InchesToPoints (float) |
Keyboard | Method | int Keyboard (int) |
KeyboardBidi | Method | void KeyboardBidi () |
KeyboardLatin | Method | void KeyboardLatin () |
KeyString | Method | string KeyString (int, Variant) |
LinesToPoints | Method | float LinesToPoints (float) |
ListCommands | Method | void ListCommands (bool) |
LookupNameProperties | Method | void LookupNameProperties (st… |
MillimetersToPoints | Method | float MillimetersToPoints (fl… |
MountVolume | Method | short MountVolume (string, st… |
Move | Method | void Move (int, int) |
NewWindow | Method | Window NewWindow () |
NextLetter | Method | void NextLetter () |
OnTime | Method | void OnTime (Variant, string,… |
OrganizerCopy | Method | void OrganizerCopy (string, s… |
OrganizerDelete | Method | void OrganizerDelete (string,… |
OrganizerRename | Method | void OrganizerRename (string,… |
PicasToPoints | Method | float PicasToPoints (float) |
PixelsToPoints | Method | float PixelsToPoints (float, … |
PointsToCentimeters | Method | float PointsToCentimeters (fl… |
PointsToInches | Method | float PointsToInches (float) |
PointsToLines | Method | float PointsToLines (float) |
PointsToMillimeters | Method | float PointsToMillimeters (fl… |
PointsToPicas | Method | float PointsToPicas (float) |
PointsToPixels | Method | float PointsToPixels (float, … |
PrintOut | Method | void PrintOut (Variant, Varia… |
PrintOutOld | Method | void PrintOutOld (Variant, Va… |
ProductCode | Method | string ProductCode () |
Quit | Method | void Quit (Variant, Variant, … |
Repeat | Method | bool Repeat (Variant) |
ResetIgnoreAll | Method | void ResetIgnoreAll () |
Resize | Method | void Resize (int, int) |
Run | Method | Variant Run (string, Variant,… |
RunOld | Method | void RunOld (string) |
ScreenRefresh | Method | void ScreenRefresh () |
SendFax | Method | void SendFax () |
SetDefaultTheme | Method | void SetDefaultTheme (string,… |
ShowClipboard | Method | void ShowClipboard () |
ShowMe | Method | void ShowMe () |
SubstituteFont | Method | void SubstituteFont (string, … |
ToggleKeyboard | Method | void ToggleKeyboard () |
FindKey | ParameterizedProperty | KeyBinding FindKey (int, Vari… |
International | ParameterizedProperty | Variant International (WdInte… |
IsObjectValid | ParameterizedProperty | bool IsObjectValid (IDispatch… |
KeysBoundTo | ParameterizedProperty | KeysBoundTo KeysBoundTo (WdKe… |
SynonymInfo | ParameterizedProperty | SynonymInfo SynonymInfo (stri… |
ActiveDocument | Property | Document ActiveDocument () {g… |
ActivePrinter | Property | string ActivePrinter () {get}… |
ActiveWindow | Property | Window ActiveWindow () {get} |
AddIns | Property | AddIns AddIns () {get} |
AnswerWizard | Property | AnswerWizard AnswerWizard () … |
Application | Property | Application Application () {g… |
Assistant | Property | Assistant Assistant () {get} |
AutoCaptions | Property | AutoCaptions AutoCaptions () … |
AutoCorrect | Property | AutoCorrect AutoCorrect () {g… |
BackgroundPrintingStatus | Property | int BackgroundPrintingStatus … |
BackgroundSavingStatus | Property | int BackgroundSavingStatus ()… |
BrowseExtraFileTypes | Property | string BrowseExtraFileTypes (… |
Browser | Property | Browser Browser () {get} |
Build | Property | string Build () {get} |
CapsLock | Property | bool CapsLock () {get} |
Caption | Property | string Caption () {get} {set} |
CaptionLabels | Property | CaptionLabels CaptionLabels (… |
CheckLanguage | Property | bool CheckLanguage () {get} {… |
COMAddIns | Property | COMAddIns COMAddIns () {get} |
CommandBars | Property | CommandBars CommandBars () {g… |
Creator | Property | int Creator () {get} |
CustomDictionaries | Property | Dictionaries CustomDictionari… |
CustomizationContext | Property | IDispatch CustomizationContex… |
DefaultSaveFormat | Property | string DefaultSaveFormat () {… |
DefaultTableSeparator | Property | string DefaultTableSeparator … |
Dialogs | Property | Dialogs Dialogs () {get} |
DisplayAlerts | Property | WdAlertLevel DisplayAlerts ()… |
DisplayAutoCompleteTips | Property | bool DisplayAutoCompleteTips … |
DisplayRecentFiles | Property | bool DisplayRecentFiles () {g… |
DisplayScreenTips | Property | bool DisplayScreenTips () {ge… |
DisplayScrollBars | Property | bool DisplayScrollBars () {ge… |
DisplayStatusBar | Property | bool DisplayStatusBar () {get… |
Documents | Property | Documents Documents () {get} |
Dummy1 | Property | bool Dummy1 () {get} |
EmailOptions | Property | EmailOptions EmailOptions () … |
EnableCancelKey | Property | WdEnableCancelKey EnableCance… |
FeatureInstall | Property | MsoFeatureInstall FeatureInst… |
FileConverters | Property | FileConverters FileConverters… |
FileSearch | Property | FileSearch FileSearch () {get} |
FocusInMailHeader | Property | bool FocusInMailHeader () {get} |
FontNames | Property | FontNames FontNames () {get} |
HangulHanjaDictionaries | Property | HangulHanjaConversionDictiona… |
Height | Property | int Height () {get} {set} |
KeyBindings | Property | KeyBindings KeyBindings () {g… |
LandscapeFontNames | Property | FontNames LandscapeFontNames … |
Language | Property | MsoLanguageID Language () {get} |
Languages | Property | Languages Languages () {get} |
LanguageSettings | Property | LanguageSettings LanguageSett… |
Left | Property | int Left () {get} {set} |
ListGalleries | Property | ListGalleries ListGalleries (… |
MacroContainer | Property | IDispatch MacroContainer () {… |
MailingLabel | Property | MailingLabel MailingLabel () … |
MailMessage | Property | MailMessage MailMessage () {g… |
MailSystem | Property | WdMailSystem MailSystem () {g… |
MAPIAvailable | Property | bool MAPIAvailable () {get} |
MathCoprocessorAvailable | Property | bool MathCoprocessorAvailable… |
MouseAvailable | Property | bool MouseAvailable () {get} |
Name | Property | string Name () {get} |
NormalTemplate | Property | Template NormalTemplate () {g… |
NumLock | Property | bool NumLock () {get} |
Options | Property | Options Options () {get} |
Parent | Property | IDispatch Parent () {get} |
Path | Property | string Path () {get} |
PathSeparator | Property | string PathSeparator () {get} |
PortraitFontNames | Property | FontNames PortraitFontNames (… |
PrintPreview | Property | bool PrintPreview () {get} {s… |
RecentFiles | Property | RecentFiles RecentFiles () {g… |
ScreenUpdating | Property | bool ScreenUpdating () {get} … |
Selection | Property | Selection Selection () {get} |
ShowVisualBasicEditor | Property | bool ShowVisualBasicEditor ()… |
SpecialMode | Property | bool SpecialMode () {get} |
StartupPath | Property | string StartupPath () {get} {… |
StatusBar | Property | {get} {set} |
System | Property | System System () {get} |
Tasks | Property | Tasks Tasks () {get} |
Templates | Property | Templates Templates () {get} |
Top | Property | int Top () {get} {set} |
UsableHeight | Property | int UsableHeight () {get} |
UsableWidth | Property | int UsableWidth () {get} |
UserAddress | Property | string UserAddress () {get} {… |
UserControl | Property | bool UserControl () {get} |
UserInitials | Property | string UserInitials () {get} … |
UserName | Property | string UserName () {get} {set} |
VBE | Property | VBE VBE () {get} |
Version | Property | string Version () {get} |
Visible | Property | bool Visible () {get} {set} |
Width | Property | int Width () {get} {set} |
Windows | Property | Windows Windows () {get} |
WindowState | Property | WdWindowState WindowState () … |
WordBasic | Property | IDispatch WordBasic () {get} |
AMAZING! I could then find the property I wanted and send it the syntax i needed, how cool !