Powershell script to findout all the software products installed in the SharePoint farm

Hi All,
Please find the simple and accurate power shell code implemented by me to generate report to get all the softwares installed on each server in the farm.It would be very helpful to create reports at farm level.
$servers = get-content F:\temp\Servers.txt
$logfile = "F:\temp\test\AllProductsInstalled.csv"
Add-content $logfile -value "ServerName,ProductName,Version,vendor,serialnumber"
foreach ($server in $servers)
$z = gwmi win32_product -ComputerName $server
foreach($a in $z)
add-content $logfile -value "$($a.__server),$($a.name),$($a.Version),$($a.IdentifyingNumber),$($a.vendor)"
Please provide the all the severnames in the text file "Servers.txt" in above code.

Why not do it in PowerShell?
$servers=get-content F:\temp\Servers.txt
$logfile='F:\temp\test\AllProductsInstalled.csv'
Get-WmiObject win32_product -ComputerName $servers |
Select-Object @{N='ServerName';E={$_.__server}},
@{N='ProductName';E={$_.Name}},
Version,Vendor,
@{N='SerialNumber';E={$_.IdentifyingNumber}} |
Export-Csv $logfile -NoType
It is much easier to let PowerShell do the work for you.
¯\_(ツ)_/¯

Similar Messages

  • Powershell script to get all the AD accounts with multiple primary SMTP addresses

    I require a script to be run in powershell for Win Server 2008 R2, to look to AD accounts with multiple primary SMTP addresses ?
    Description: In my Organization, there can be a configuration error which might have resulted in multiple primary SMTP addresses to be assigned to a user. I want to get the list of these AD accounts which have multiple primary SMTP addresses

    Hi,
    You can use the PowerShell command given below to get the AD User name and primary smtp address in a OU,
    Get-ADuser -filter {proxyAddresses -like "*"} -searchbase "ou=testOU,dc=MyDomain,dc=local" -properties * | select name,proxyaddresses | fl
    NOTE: proxyAddresses attribute in AD User matches the primary SMTP address.
    Regards,
    Gopi
    JiJi
    Technologies

  • Powershell script to get all user profiles with specific email address

    Hello,
    Please help me. I need a powershell script which can do the following things.
    List of all sharepoint user profiles with email address
    [email protected]
    List of all FBA user profiles with email address  [email protected]
         List of all Pending Access Requests
    Any help is much appreciated. Thanks.
    chirag

    The script is not working for me. I changed the url according to my site. See the below error
    New-Object : Exception calling ".ctor" with "1" argument(s):
    "UserProfileApplicationNotAvailableException_Logging ::
    UserProfileApplicationProxy.ApplicationProperties ProfilePropertyCache does
    not have 3f3a5705-0691-4fe8-8643-cccd65363dc9"
    At C:\Scripts\userprofileemails.ps1:11 char:19
    + $profileManager = New-Object
    Microsoft.Office.Server.UserProfiles.UserProfileMan ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ~~~
        + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvoca
       tionException
        + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
       Shell.Commands.NewObjectCommand
    You cannot call a method on a null-valued expression.
    At C:\Scripts\userprofileemails.ps1:12 char:1
    + $profiles = $profileManager.GetEnumerator()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
    Please guide me what to do on this.
    Thanks
    chirag

  • PowerShell script to list ALL documents bigger than 10MB - in list attachments/libraries all over my site?

    Hi there,
    Just wondering if someone can give me the PowerShell script to list ALL documents bigger than 10MB - in list attachments/libraries all over my site?
    Really appreciated.
    Thank you.

    Hello,
    here you can find sample to help you create yoru script :
    http://sharepointpromag.com/sharepoint/windows-powershell-scripts-sharepoint-info-files-pagesweb-parts
    see this sample extract from this site
    Get-SPWeb http://sharepoint/sites/training |
                                     Select -ExpandProperty Lists |
                                     Where { $_.GetType().Name -eq "SPDocumentLibrary" -and
                                             -not $_.Hidden }
    |
                                     Select -ExpandProperty Items |
                                     Where { $_.File.Length -gt 5000 } |
                                     Select Name, {$_.File.Length},
                                            @{Name="URL";
                                            Expression={$_.ParentList.ParentWeb.Url
    + "/" + $_.Url}}
    this can help too :
    https://gallery.technet.microsoft.com/office/Get-detail-report-of-all-b29ea8e2
    Best regards, Christopher.
    Blog |
    Mail
    Please remember to click "Mark As Answer" if a post solves your problem or
    "Vote As Helpful" if it was useful.
    Why mark as answer?

  • Looking for a Powershell Script which can put the scom servers in maintenance mode

    Looking for a Powershell Script which can put the scom servers in maintenance mode so that SCOM should not send an alert during planned task.
    Rahul

    1. Provide list of servers line-by-line in C:\ServerList.txt, make sure you provide limited no. of servers, do not exceed 20 - 25 per batch
    2. Save the script with suitable name (test.ps1)
    3. Open PowerShell cmd prompt
    4. Script accepts 3 params - TimeInMinutes, Reason and Comment
    **** Please note, this script will work for SCOM 2012 R2
    param([int32]$TimeMin, [string]$Reason, [string]$Comment)
    try
    $api = new-object -comObject 'MOM.ScriptAPI'
    Import-Module operationsmanager
    New-SCOMManagementGroupConnection
    $Servers = Get-Content "C:\ServerList.txt"
    $Time = (Get-Date).Addminutes($TimeMin)
    Foreach ($Server in $Servers)
    #Get Computer instance
    $ComputerClass = Get-SCOMClass -Name Microsoft.Windows.Computer
    $ComputerClassInstance = Get-SCOMClassInstance  -Class $ComputerClass | Where {$_.DisplayName -eq $Server}
    If ($ComputerClassInstance -ne $Null)
    $HealthServiceWatcherClass = Get-SCOMClass -name:Microsoft.SystemCenter.HealthServiceWatcher
    #Get Health Service Watcher Class instance of the server
    $HSWClass = Get-SCOMClass -Name Microsoft.SystemCenter.HealthServiceWatcher
    $HSWClassIns = Get-SCOMClassInstance  -Class $HSWClass | Where {$_.DisplayName -eq $Server}
    #Starting the maintenance mode
    Start-SCOMMaintenanceMode -Instance $HSWClassIns -EndTime $Time -Reason $Reason -Comment $Comment
    Start-SCOMMaintenanceMode -Instance $ComputerClassInstance -EndTime $Time  -Reason $Reason -Comment $Comment
    Write-Host "Health Service Watcher and Agent server "$Server " kept in maintenance mode"  -foregroundcolor "green"
    $api.LogScriptEvent('MaintenanceModeScript.ps1', 200, 0, "$Server kept in maintenance mode for $TimeMin minutes")
    Else
    Write-Host $Server" not found " -foregroundcolor "red"
    $api.LogScriptEvent('MaintenanceModeScript.ps1', 201, 1, "$Server could not be found in domain")
    Catch [system.exception]
    $api.LogScriptEvent('MaintenanceModeScript.ps1', 201, 1, $_.Exception.Message)
    Faizan

  • How can i findout all the payement servicetax line items?

    Hello Experts,
    How can i find out all the clearing document numbers which are consisting servicetax in a particular month?
    Ex:lets say,1 st aug to 31 st aug-08/what ever payments i have done that generates a clearing doc.no.right?now my requirement is to findout all the clearing doc nos in a particiular month and that payment shud consist service tax.it is to know the total servicetax sredit amount in a particular month?
    Is it possible to know?
    plz suggest?
    its highly requirement.
    Regards,
    biswa

    Hello Experts,
    How can i find out all the clearing document numbers which are consisting servicetax in a particular month?
    Ex:lets say,1 st aug to 31 st aug-08/what ever payments i have done that generates a clearing doc.no.right?now my requirement is to findout all the clearing doc nos in a particiular month and that payment shud consist service tax.it is to know the total servicetax sredit amount in a particular month?
    Is it possible to know?
    plz suggest?
    its highly requirement.
    Regards,
    biswa

  • What is the best way to run a powershell script with parameters in the Task Scheduler?

    Hello, 
    Want to run the following from a scheduled task in the Task Scheduler on a server.  What is the best approach?
    .\pscript.ps1 -csvfile "\\Srv1\Share\File.txt"
    Thanks for your help! SdeDot

    Hi,
    To run a powershell script with parameters in the Task Scheduler:
    Program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Add argument (optional): -Command "& c:\scripts\test.ps1 -par1 2 -par2 3"
    Hope the below two articles be helpful for you:
    Schedule PowerShell Scripts that Require Input Values
    https://blogs.technet.com/b/heyscriptingguy/archive/2011/01/12/schedule-powershell-scripts-that-require-input-values.aspx
    How to Schedule a PowerShell Script
    http://dmitrysotnikov.wordpress.com/2011/02/03/how-to-schedule-a-powershell-script/
    Regards,
    Yan Li
    Regards, Yan Li

  • Script to generate all the tables and objects in a schema

    how to write a script to generate all the tables and objects in a schema.
    with toad the no of tables generated is not matching when i check from schema .

    Dear Sidhant,
    Try this script:
    set termout off
    set feedback off
    set serveroutput on size 100000
    spool ddl_schema.sql
    begin
    dbms_output.put_line('--');
    dbms_output.put_line('-- DROP TABLES --');
    dbms_output.put_line('--');
        for rt in (select tname from tab order by tname) loop
            dbms_output.put_line('DROP TABLE '||rt.tname||' CASCADE CONSTRAINTS;');
        end loop;
    end;
    declare
        v_tname  varchar2(30);
        v_cname  char(32);
        v_type     char(20);
        v_null   varchar2(10);
        v_maxcol number;
        v_virg     varchar2(1);
    begin
    dbms_output.put_line('--');
    dbms_output.put_line('-- CREATE TABLES --');
    dbms_output.put_line('--');
        for rt in (select table_name from user_tables order by 1) loop
            v_tname:=rt.table_name;
            v_virg:=',';
            dbms_output.put_line('CREATE TABLE '||v_tname||' (');
            for rc in (select table_name,column_name,data_type,data_length,
                                data_precision,data_scale,nullable,column_id
                    from user_tab_columns tc
                    where tc.table_name=rt.table_name
                    order by table_name,column_id) loop
                        v_cname:=rc.column_name;
                        if rc.data_type='VARCHAR2' then
                            v_type:='VARCHAR2('||rc.data_length||')';
                        elsif rc.data_type='NUMBER' and rc.data_precision is null and
                                             rc.data_scale=0 then
                            v_type:='INTEGER';
                        elsif rc.data_type='NUMBER' and rc.data_precision is null and
                                         rc.data_scale is null then
                            v_type:='NUMBER';
                        elsif rc.data_type='NUMBER' and rc.data_scale='0' then
                            v_type:='NUMBER('||rc.data_precision||')';
                        elsif rc.data_type='NUMBER' and rc.data_scale<>'0' then
                            v_type:='NUMBER('||rc.data_precision||','||rc.data_scale||')';
                        elsif rc.data_type='CHAR' then
                             v_type:='CHAR('||rc.data_length||')';
                        else v_type:=rc.data_type;
                        end if;
                        if rc.nullable='Y' then
                            v_null:='NULL';
                        else
                            v_null:='NOT NULL';
                        end if;
                        select max(column_id)
                            into v_maxcol
                            from user_tab_columns c
                            where c.table_name=rt.table_name;
                        if rc.column_id=v_maxcol then
                            v_virg:='';
                        end if;
                        dbms_output.put_line (v_cname||v_type||v_null||v_virg);
            end loop;
            dbms_output.put_line(');');
        end loop;
    end;
    declare
        v_virg        varchar2(1);
        v_maxcol    number;
    begin
    dbms_output.put_line('--');
    dbms_output.put_line('-- PRIMARY KEYS --');
    dbms_output.put_line('--');
        for rcn in (select table_name,constraint_name
                from user_constraints
                where constraint_type='P'
                order by table_name) loop
            dbms_output.put_line ('ALTER TABLE '||rcn.table_name||' ADD (');
            dbms_output.put_line ('CONSTRAINT '||rcn.constraint_name);
            dbms_output.put_line ('PRIMARY KEY (');
            v_virg:=',';
            for rcl in (select column_name,position
                    from user_cons_columns cl
                    where cl.constraint_name=rcn.constraint_name
                    order by position) loop
                select max(position)
                    into v_maxcol
                    from user_cons_columns c
                    where c.constraint_name=rcn.constraint_name;
                if rcl.position=v_maxcol then
                    v_virg:='';
                end if;
                dbms_output.put_line (rcl.column_name||v_virg);
            end loop;
            dbms_output.put_line(')');
            dbms_output.put_line('USING INDEX );');
        end loop;
    end;
    declare
        v_virg        varchar2(1);
        v_maxcol    number;
        v_tname        varchar2(30);
    begin
    dbms_output.put_line('--');
    dbms_output.put_line('-- FOREIGN KEYS --');
    dbms_output.put_line('--');
        for rcn in (select table_name,constraint_name,r_constraint_name
                from user_constraints
                where constraint_type='R'
                order by table_name) loop
            dbms_output.put_line ('ALTER TABLE '||rcn.table_name||' ADD (');
            dbms_output.put_line ('CONSTRAINT '||rcn.constraint_name);
            dbms_output.put_line ('FOREIGN KEY (');
            v_virg:=',';
            for rcl in (select column_name,position
                    from user_cons_columns cl
                    where cl.constraint_name=rcn.constraint_name
                    order by position) loop
                select max(position)
                    into v_maxcol
                    from user_cons_columns c
                    where c.constraint_name=rcn.constraint_name;
                if rcl.position=v_maxcol then
                    v_virg:='';
                end if;
                dbms_output.put_line (rcl.column_name||v_virg);
            end loop;
            select table_name
                into v_tname
                from user_constraints c
                where c.constraint_name=rcn.r_constraint_name;
            dbms_output.put_line(') REFERENCES '||v_tname||' (');
            select max(position)
                    into v_maxcol
                    from user_cons_columns c
                    where c.constraint_name=rcn.r_constraint_name;
            v_virg:=',';
            select max(position)
                into v_maxcol
                from user_cons_columns c
                where c.constraint_name=rcn.r_constraint_name;
            for rcr in (select column_name,position
                    from user_cons_columns cl
                    where rcn.r_constraint_name=cl.constraint_name
                    order by position) loop
                if rcr.position=v_maxcol then
                    v_virg:='';
                end if;
                dbms_output.put_line (rcr.column_name||v_virg);
            end loop;
            dbms_output.put_line(') );');
        end loop;
    end;
    begin
    dbms_output.put_line('--');
    dbms_output.put_line('-- DROP SEQUENCES --');
    dbms_output.put_line('--');
        for rs in (select sequence_name
                from user_sequences
                where sequence_name like 'SQ%'
                order by sequence_name) loop
            dbms_output.put_line('DROP SEQUENCE '||rs.sequence_name||';');
        end loop;
    dbms_output.put_line('--');
    dbms_output.put_line('-- CREATE SEQUENCES --');
    dbms_output.put_line('--');
        for rs in (select sequence_name
                from user_sequences
                where sequence_name like 'SQ%'
                order by sequence_name) loop
            dbms_output.put_line('CREATE SEQUENCE '||rs.sequence_name||' NOCYCLE;');
        end loop;
    end;
    declare
        v_virg        varchar2(1);
        v_maxcol    number;
    begin
    dbms_output.put_line('--');
    dbms_output.put_line('-- INDEXES --');
    dbms_output.put_line('--');
        for rid in (select index_name, table_name
                from user_indexes
                where index_name not in (select constraint_name from user_constraints)
                    and index_type<>'LOB'
                order by index_name) loop
            v_virg:=',';
            dbms_output.put_line('CREATE INDEX '||rid.index_name||' ON '||rid.table_name||' (');
            for rcl in (select column_name,column_position
                    from user_ind_columns cl
                    where cl.index_name=rid.index_name
                    order by column_position) loop
                select max(column_position)
                    into v_maxcol
                    from user_ind_columns c
                    where c.index_name=rid.index_name;
                if rcl.column_position=v_maxcol then
                    v_virg:='';
                end if;
                dbms_output.put_line (rcl.column_name||v_virg);
            end loop;
            dbms_output.put_line(');');
        end loop;
    end;
    spool off
    set feedback on
    set termout on Best Regards,
    Francisco Munoz Alvarez
    www.oraclenz.com

  • Powershell script not running in the task scheduler...

    I've created a .ps1 script to transfer a file using WinSCP can run it in the ISE environment, in the PS window, and with the run command. I've transferred the command I used in the run prompt to the task scheduler but it is not running. It is running everywhere
    else just not in the scheduler. It says that it completes okay and gives a return code of OpCode=2
    The action is set to run this: c:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe
    The Arguments: -ExecutionPolicy Bypass -file "C:\Users\me\scriptsWCP\FileTransferPS.ps1"
    Also have it running with the highest permission and as SYSTEM

    Hi,
    To run a powershell script with parameters in the Task Scheduler:
    Program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Add argument (optional): -Command "& c:\scripts\test.ps1 -par1 2 -par2 3"
    Hope the below two articles be helpful for you:
    Schedule PowerShell Scripts that Require Input Values
    https://blogs.technet.com/b/heyscriptingguy/archive/2011/01/12/schedule-powershell-scripts-that-require-input-values.aspx
    How to Schedule a PowerShell Script
    http://dmitrysotnikov.wordpress.com/2011/02/03/how-to-schedule-a-powershell-script/
    Regards,
    Yan Li
    Regards, Yan Li

  • Script that deletes all the data in the DB

    Somebody has or know a script that delete all the data (but not the tables) of the database???? I have dummy data and know I need the tables clean of data.
    How can I delete it???????? Thank you for you help
    Javier

    You could truncate all the tables with the following commandTRUNCATE TABLE <table_name>;This will delete all the data in the table while keeping the table structure, contraints, indexes, triggers, etc. intact so they wont have to be rebuilt. All foreign keys must be disabled to use the TRUNCATE command.

  • Script to get all the Server Names on Central Site in the SCCM 2007 Hierarchy

    I want a script which will run on Central Site, and give all the SCCM server names in the hierarchy.
    Thanks and Regards, Mohd Zaid www.techforcast.com

    Duplicated post of
    http://social.technet.microsoft.com/Forums/systemcenter/en-US/97910cd5-8f8b-46a7-86fa-c00932571d0d/script-to-get-all-the-server-names-on-central-site-in-the-sccm-2007-heirarchy?forum=configmgrgeneral
    Garth Jones | My blogs: Enhansoft and
    Old Blog site | Twitter:
    @GarthMJ

  • PowerShell script doesn't appear to work as scheduled task in sharepoint 2013

    PowerShell script doesn't appear to work as scheduled task in sharepoint 2013, it works as normal manual execution
    MCTS Sharepoint 2010, MCAD dotnet, MCPDEA, SharePoint Lead

    Hi,
    To run PowerShell Script as scheduled task in SharePoint 2013, you can take the demo below for a try:
    http://blogs.technet.com/b/meamcs/archive/2013/02/23/sharepoint-2013-backup-with-powershell-and-task-scheduler-for-beginners.aspx
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
    contact [email protected]
    Patrick Liang
    TechNet Community Support

  • Wiso I can on my WIndows XP, no iTunes, and all other Apple products instalation?

    wiso I can on my WIndows XP, no iTunes, and all other Apple products instalation?

    Perhaps it's me, but I have no idea what that sentence is meant to mean. Did you simply copy-and-paste groups of words from somewhere else?

  • Powershell script to get list of softwares installed as shown in registry on all the remote systems in a txt file

    Hi
    I need to know the command for getting list of softwares installed on all the remote systems in network  which are existing in their respective registry like HKEY_LOCAL_MACHINE\SOFTWARE of all other systems

    Hey
    Sorry this isn't powershell but it should do the job if you want to use it. The problem with using the Win32_Product WMI Class to enumerate the installed software (especially on Windows 2000 & 2003 Servers) is that the WMI class is NOT installed by default. Here is a VBScript i wrote to read a list of hostnames from a text file named "ComputerNames.txt" from the scripts directory and attempt to remotely enumerate all subkeys within the following registry key
    HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall
    For each subkey enumerated it will attempt to read the value of the "DisplayName" key and output the results to a csv file.
    (the results should be the same as what you would see when you open Add/Remove Programs)
    Hope that helps
    Cheers
    Matt :)
    'Script Name : CheckInstalledSoftware.vbs
    'Author : Matthew Beattie
    'Created : 01/03/10
    'Description : This script reads a list of hostnames from a text file name "ComputerNames.txt" in the scripts working
    ' : directory. For each hostName it requests an ICMP response and if successfull attempts a remote registry
    ' : connection to enumerate and read the registry values of installed software. All results are logged to the
    ' : scripts working directory in a log file per computer name.
    'Initialization Section
    Option Explicit
    Const ForReading = 1
    Const ForAppending = 8
    Dim objFSO, wshNetwork, wshShell, hostName
    Dim scriptBaseName, scriptPath, scriptLogPath
    On Error Resume Next
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set wshShell = CreateObject("WScript.Shell")
    Set wshNetwork = CreateObject("WScript.Network")
    scriptBaseName = objFSO.GetBaseName(Wscript.ScriptFullName)
    scriptPath = objFSO.GetFile(Wscript.ScriptFullName).ParentFolder.Path
    scriptLogPath = scriptPath & "\" & IsoDateString(Now)
    If Err.Number <> 0 Then
    Wscript.Quit
    End If
    On Error Goto 0
    'Main Processing Section
    On Error Resume Next
    PromptStart
    ProcessScript
    If Err.Number <> 0 Then
    Wscript.Quit
    End If
    PromptEnd
    On Error Goto 0
    'Functions Processing Section
    'Name : ProcessScript -> Primary Function that controls all other script processing.
    'Parameters : None ->
    'Return : None ->
    Function ProcessScript
    Dim fileSpec, hostNames, regKey, keyName, results, result
    keyName = "DisplayName"
    regKey = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    fileSpec = scriptPath & "\ComputerNames.txt"
    'Ensure the "ComputerNames.txt" file exists within the scripts working directory.
    If Not objFSO.FileExists(fileSpec) Then
    MsgBox DQ(fileSpec) & " does not exist!", vbCritical, scriptBaseName
    Exit Function
    End If
    'Read the list of hostNames from the "ComputerNames.txt" text file within the scripts working directory.
    If Not GetScriptInput(hostNames, fileSpec) Then
    Exit Function
    End If
    'Attempt to read the registry from each hostname read from the list of hostnames.
    For Each hostName In hostNames
    Do
    'Ensure the system responds to an ICMP request.
    If Not CheckConnection(hostName) Then
    LogMessage 2, "Failed to respond to an ICMP Request"
    Exit Do
    End If
    'Enumerate and read the registry values.
    If Not GetRegValues(results, hostName, keyName, regKey) Then
    Exit Do
    End If
    'Log the registry values results.
    For Each result In results
    LogMessage 0, result
    Next
    Loop Until True
    Next
    End Function
    'Name : GetScriptInput -> Reads a text file to be used as Script input.
    'Parameters : items -> Output: An array of items in the script input file.
    ' : fileSpec -> The full folder Path, file Name and extention of the script input file.
    'Return : GetScriptInput -> Returns an array of items for script input and True or False.
    Function GetScriptInput(items, fileSpec)
    Dim scriptInputFile, itemsDict, item
    GetScriptInput = False
    Set itemsDict = NewDictionary
    If Not objFSO.FileExists(fileSpec) Then
    Exit Function
    End If
    On Error Resume Next
    Set scriptInputFile = objFSO.OpenTextFile(fileSpec, ForReading)
    If Err.Number <> 0 Then
    Exit Function
    End If
    On Error Goto 0
    Do Until scriptInputFile.AtEndOfStream
    item = scriptInputFile.ReadLine
    If item = "" Then
    Exit Function
    End If
    If Not itemsDict.Exists(item) Then
    itemsDict.Add item, ""
    End If
    Loop
    items = itemsDict.Keys
    GetScriptInput = True
    End Function
    'Name : CheckConnection -> Checks a remote host using WMI ping.
    'Parameters : hostName -> Hostname of computer system to verify network connectivity with.
    'Return : Boolean -> True if hostname replies. False otherwise.
    Function CheckConnection(hostName)
    Dim ping, response, replied
    Set ping = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
    ("select * from Win32_PingStatus where address = '" & hostName & "'")
    For each response in ping
    replied = Not IsNull(response.StatusCode) And response.StatusCode = 0
    Next
    CheckConnection = replied
    End Function
    'Name : GetRegValues -> Enumerates the subkeys in a registry key and the values of the keyName.
    'Parameters : hostName -> String containing the hostName of the system to enumerate the registry keys on.
    ' : keyName -> String containing the name of the registry key value to enumerate.
    ' : regKey -> Registry key to enumerate subkey names for.
    'Return : GetRegValues -> Returns True and an Array containing the registry key values otherwise False.
    Function GetRegValues(results, hostName, keyName, regKey)
    Dim objReg, regDict, rootKey, hive, keyValue, subKeys, i
    GetRegValues = False
    rootKey = regKey
    hive = GetRegistryHiveFromKey(rootKey)
    On Error Resume Next
    If hive <> 0 Then
    'Create a dictionary object to store the registry values in.
    Set regDict = NewDictionary
    If Err.Number <> 0 Then
    LogMessage 1, "Creating Dictionary Object"
    Exit Function
    End If
    'Connect to the remote registry.
    Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & hostName & "\root\default:StdRegProv")
    If Err.Number <> 0 Then
    LogMessage 1, "Creating StdRegProv Object"
    Exit Function
    End If
    'Enumerate the subkey names within the regKey paramater.
    objReg.EnumKey hive, rootKey, subKeys
    If Err.Number <> 0 Then
    LogMessage 1, "Enumerating Registry Keys"
    Exit Function
    End If
    'Ensure the results are an array.
    If Not IsArray(subKeys) Then
    subKeys = Array(subKeys)
    End If
    'Read the registry key value for each subkey. Add the results to the dictionary.
    For i = 0 to UBound(subKeys)
    objReg.GetStringValue hive, rootKey & "\" & subKeys(i), keyName, keyValue
    If Err.Number = 0 Then
    If Not IsNull(keyValue) Then
    regDict(regDict.Count) = keyValue
    End If
    Else
    Err.Clear
    End If
    Next
    End If
    On Error Goto 0
    results = regDict.Items
    GetRegValues = True
    End Function
    'Name : GetRegistryHiveFromKey -> Get the hive ID from a registry key name.
    'Parameters: Input/Output: key -> Registry key name. Hive name will be removed.
    'Return : GetRegistryHiveFromKey -> ID of hive of given key name (0 if invalid).
    ' : -> The hive name is removed from the input key name.
    Function GetRegistryHiveFromKey (key)
    Dim pos, hive
    pos = Instr (key, "\")
    If pos = 0 Then
    pos = Len(key) + 1
    End If
    hive = Left (UCase (Left (key, pos - 1)) & " ", 4)
    key = Mid (key, pos + 1)
    GetRegistryHiveFromKey = Array(0, &H80000000, &H80000001, &H80000002, &H80000003, &H80000005, &H80000006) _
    (Int ((Instr("HKCR,HKCU,HKLM,HKU ,HKCC,HKDD", hive) + 4) / 5))
    End Function
    'Name : NewDictionary -> Creates a new dictionary object.
    'Parameters : None ->
    'Return : NewDictionary -> Returns a dictionary object.
    Function NewDictionary
    Dim dict
    Set dict = CreateObject("scripting.Dictionary")
    dict.CompareMode = vbTextCompare
    Set NewDictionary = dict
    End Function
    'Name : DQ -> Place double quotes around a string and replace double quotes
    ' : -> within the string with pairs of double quotes.
    'Parameters : stringValue -> String value to be double quoted
    'Return : DQ -> Double quoted string.
    Function DQ (ByVal stringValue)
    If stringValue <> "" Then
    DQ = """" & Replace (stringValue, """", """""") & """"
    Else
    DQ = """"""
    End If
    End Function
    'Name : IsoDateTimeString -> Generate an ISO date and time string from a date/time value.
    'Parameters : dateValue -> Input date/time value.
    'Return : IsoDateTimeString -> Date and time parts of the input value in "yyyy-mm-dd hh:mm:ss" format.
    Function IsoDateTimeString(dateValue)
    IsoDateTimeString = IsoDateString (dateValue) & " " & IsoTimeString (dateValue)
    End Function
    'Name : IsoDateString -> Generate an ISO date string from a date/time value.
    'Parameters : dateValue -> Input date/time value.
    'Return : IsoDateString -> Date part of the input value in "yyyy-mm-dd" format.
    Function IsoDateString(dateValue)
    If IsDate(dateValue) Then
    IsoDateString = Right ("000" & Year (dateValue), 4) & "-" & _
    Right ( "0" & Month (dateValue), 2) & "-" & _
    Right ( "0" & Day (dateValue), 2)
    Else
    IsoDateString = "0000-00-00"
    End If
    End Function
    'Name : IsoTimeString -> Generate an ISO time string from a date/time value.
    'Parameters : dateValue -> Input date/time value.
    'Return : IsoTimeString -> Time part of the input value in "hh:mm:ss" format.
    Function IsoTimeString(dateValue)
    If IsDate(dateValue) Then
    IsoTimeString = Right ("0" & Hour (dateValue), 2) & ":" & _
    Right ("0" & Minute (dateValue), 2) & ":" & _
    Right ("0" & Second (dateValue), 2)
    Else
    IsoTimeString = "00:00:00"
    End If
    End Function
    'Name : LogMessage -> Parses a message to the log file based on the messageType.
    'Parameters : messageType -> Integer representing the messageType.
    ' : -> 0 = message (writes to a ".csv" file)
    ' : -> 1 = error, (writes to a ".err" file including information relating to the error object.)
    ' : -> 2 = error message (writes to a ".err" file without information relating to the error object.)
    ' : message -> String containing the message to write to the log file.
    'Return : None ->
    Function LogMessage(messageType, message)
    Dim prefix, logType
    prefix = hostName
    Select Case messageType
    Case 0
    logType = "csv"
    Case 1
    logType = "err"
    message = "Error " & Err.Number & " (Hex " & Hex(Err.Number) & ") " & message & ". " & Err.Description
    Case Else
    LogType = "err"
    End Select
    If Not LogToCentralFile(scriptLogPath & "." & logType, hostName & "," & message) Then
    Exit Function
    End If
    End Function
    'Name : LogToCentralFile -> Attempts to Appends information to a central file.
    'Parameters : logSpec -> Folder path, file name and extension of the central log file to append to.
    ' : message -> String to include in the central log file
    'Return : LogToCentralFile -> Returns True if Successfull otherwise False.
    Function LogToCentralFile(logSpec, message)
    Dim attempts, objLogFile
    LogToCentralFile = False
    'Attempt to append to the central log file up to 10 times, as it may be locked by some other system.
    attempts = 0
    On Error Resume Next
    Do
    Set objLogFile = objFSO.OpenTextFile(logSpec, ForAppending, True)
    If Err.Number = 0 Then
    objLogFile.WriteLine message
    objLogFile.Close
    LogToCentralFile = True
    Exit Function
    End If
    Randomize
    Wscript.sleep 1000 + Rnd * 100
    attempts = attempts + 1
    Loop Until attempts >= 10
    On Error Goto 0
    End Function
    'Name : PromptStart -> Prompt when script starts.
    'Parameters : None ->
    'Return : None ->
    Function PromptStart
    MsgBox "Now processing the " & DQ(Wscript.ScriptName) & " script.", vbInformation, scriptBaseName
    End Function
    'Name : PromptEnd -> Prompts when script has completed.
    'Parameters : None ->
    'Return : None ->
    Function PromptEnd
    MsgBox "The " & DQ(Wscript.ScriptName) & " script has completed successfully.", vbInformation, scriptBaseName
    End Function
    'Name : PromptError -> Prompts when an unexpected script error occurs.
    'Parameters : None ->
    'Return : None ->
    'Function PromptEnd
    ' MsgBox "Error " & Err.Number & " (Hex " & Hex(Err.Number) & "). " & Err.Description, vbCritical, scriptBaseName
    'End Function

  • How can I use PowerShell 3.0 cmdlets or script to list all the local groups and local users of a server?

    Using PowerShell 3.0 (And if possible the CIM, not WMI cmdlet), how can I script with | out-file C:\<filename>.txt or .csv option to list all local user accounts & local groups
    on remote computers? 
    Thank You!

    I don't recall PowerShell V3 introducing anything new to handle local users and groups. You need to use PowerShell V1 methods, using the [ADSI] accelerator and the WinNT: provider. The scripts linked above show this. No need to use WMI (which would probably
    be slower).
    Here is a script I've used to enumerate all local groups and their members:
    $Computer
    = "MyServer"
    $Computer =
    [ADSI]"WinNT://$Computer"
    $Groups =
    $Computer.psbase.Children | Where {$_.psbase.schemaClassName
    -eq "group"}
    ForEach ($Group
    In $Groups)
        "Group: "
    + $Group.Name
        $Members
    = @($Group.psbase.Invoke("Members"))
        ForEach ($Member
    In $Members)
            $Class
    = $Member.GetType().InvokeMember("Class",
    'GetProperty', $Null,
    $Member, $Null)
            $Name
    = $Member.GetType().InvokeMember("Name",
    'GetProperty', $Null,
    $Member, $Null)
            "-- Member: $Name ($Class)"
    A similar script to enumerate all local users would be:
    $Computer
    = "MyServer"
    $Computer =
    [ADSI]"WinNT://$Computer"
    $Users =
    $Computer.psbase.Children | Where {$_.psbase.schemaClassName
    -eq "user"}
    ForEach ($User
    In $Users)
        "User: "
    + $User.Name
    Richard Mueller - MVP Directory Services

Maybe you are looking for

  • Auto GR Receipt based on ASN Quantity

    Hi Friends, Can you please tell me, in which BADI, I can write code for following steps 1. Check the Shipping Quantity in the ASN ( Advance Shipment Notification )and   the Order Quantity in the PO 2. Check the tolerance 3. If the Shipped Quantity is

  • What is the transfer rate of the ata interface in hp pavillion g4-1117dx

    I am looking at replacing hdd for my hp pavillion g4-1117dx with a ssd. I would like to know if the existing hdd interface copes with ssd's transfer rate at 6G? Thanks This question was solved. View Solution.

  • How to update firefox suse linux enterprise 10.3

    I've recently installed Suse Linux Enterprise Server 10 sp3. It has firefox 3.5.2. I'd like to know how to update it to the latest version. I've downloaded and decompressed the firefox file but cannot install it (update the residetn version). Thanks

  • Feature-based Licensing and Timer-based Licensing

    Can we combine both licencing, which I would need to market my application for users from different countries interested in testing for a certain time their specific language application of interest featured in the application?

  • "Excluding" selection in query

    Hello guys, I was testing a report for the BI team and ran analysis in RSECADMIN. i was surprised to see that one of the authorization errors was charecteristic (attribute level) 0sales_off is being checked for "not equal to" for value BEA (sales off