Quantcast
Channel: THWACK: Popular Discussions - Script Lab
Viewing all 9937 articles
Browse latest View live

No result for Powershell script "Get-ADUser" in cross domain remote server (domain member server)

$
0
0

Hello Everyone,

I got a requirement to work on AD user details monitoring through SAM. I wrote a script and it is working fine when I am running it on Orion Poller itself locally for a user which is in same domain as my poller server is member of.

When I ran the same on a remote server which is not in the same domain then it is not giving me the details. Though PSSession is enabled though we are getting below error -

*************************************************************************************************************************************************************************************************************************

Errors: ==============================================

Get-ADUser : Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web Services running.

At line:2 char:6

+ $B = Get-ADUser -filter {samaccountname -eq $A -and Enabled -eq $True -and Passw ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  + CategoryInfo : ResourceUnavailable: (:) [Get-ADUser], ADServerDownException

  + FullyQualifiedErrorId : ActiveDirectoryServer:0,Microsoft.ActiveDirectory.Management.Commands.GetADUser

 

 

*************************************************************************************************************************************************************************************************************************

 

Is there any limitation in SAM  power shell to run "Get-ADUser" on a remote server in different domain. Because if we are running any other power shell script then it is not showing any error simply giving us desired result also when we are running SAM power shell from its domain Solar winds Orion then it is giving the result. Only cross domain is not working.


acknowledged alerts report

$
0
0

Hi guys,

 

As we all know that events are triggered as alerts and then alerts gets acknowledged/reset/deleted. I would like to learn more what exactly happens when an alert is acknowledged ? I believe it gets recorded in the Alerts Status table of DB, but what if its acknowledged and reset both ? will it still remain in the Alerts status table or gets cleared/deleted from the database ? I think it is removed from the Alert status table, but i am not sure where it goes ? Please correct me if i am wrong...

Powershell and Named Pipes

$
0
0

This was done based on some posts related to getting data into SAM from external sources. For example when SAM itself cannot run code to get to the data.

 

For a proof of concept create a Windows Powershell Monitor with the attached code in ps_pipe_1.txt. You want to test the script output against a device where you know the poller name. So get the script output, select your device and no authentication should be needed. From a second computer you'll run the code ps_pipe_2.txt (you'll need to rename it to .ps1 for Powershell to work.) You'll also need to edit the first line and change the "POLLER_WHERE_SCRIPT_IS_RUNNING" to your poller name. The script generates a random number. You should see that in the Output Results of your Powershell monitor.

 

Enjoy,

Steve

PowerShell Issue - SQL Job Monitor

$
0
0

So. Frustrated. (but I'm sure it's something small that I'm overlooking!)

 

I have this code:

 

Import-Module SQLPS 3>$null

[System.Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.SMO.dll") | Out-Null

 

$sql = " ;WITH CTE_MostRecentJobRun AS

(

-- For each job get the most recent run (this will be the one where Rnk=1)

  SELECT job_id

    ,run_status

    ,run_date

    ,run_time

    ,RANK() OVER (PARTITION BY job_id ORDER BY run_date DESC,run_time DESC) AS Rnk

  FROM sysjobhistory

  WHERE step_id=0

)

SELECT

  name AS [JobName],

  run_status

  ,CONVERT(VARCHAR,DATEADD(S,(run_time/10000)*60*60 /* hours */

     +((run_time - (run_time/10000) * 10000)/100) * 60 /* mins */

     +(run_time - (run_time/100) * 100) /* secs */

  ,CONVERT(DATETIME,RTRIM(run_date),113)),100) AS [TimeRun]

FROM CTE_MostRecentJobRun MRJR

  JOIN sysjobs SJ ON MRJR.job_id=sj.job_id

WHERE Rnk=1

  /* AND run_status=0 */

  AND name LIKE 'CN%'

  AND [enabled] = 1

ORDER BY name"

 

$sqlJobs = @(Invoke-Sqlcmd -ServerInstance <MYDBINSTANCE> -Database msdb -Query $sql)

 

$i = 1

$successCount = 1

 

Foreach ($sqlJob in $sqlJobs){

    Write-Host "Statistic.$($i):  "$sqlJob.run_status

    Write-Host "Message.$($i):  "$sqlJob.JobName.tostring()

    $successCount++

    $i++}

 

If ($successCount = $i){

exit 0 }

Else {

exit 1 }

 

It works perfectly fine when I run it in the ISE, but SAM keeps throwing back "Not Defined".  What am I doing wrong?!

 

Thank you,

Jack Vaughan, Jr.

Help with custom PowerShell monitor

$
0
0

I am trying to monitor the search index for SharePoint.

 

I would need to monitor when the state for index component state= degraded

 

anyone able to help me create a custom monitor?

the powershell command would be:

 

$ssappn = Get-SPEnterpriseSearchServiceApplication

Get-SPEnterpriseSearchStatus –SearchApplication $ssappn[0].Name

purna-degradedserviceappn.png

 

My super quick attempt to write a PS monitor.

 

$ErrorActionPreference = "silentlycontinue";

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$Error.Clear();

$stat1=$stat2=$stat3=$stat4=0;

$ssappn = Get-SPEnterpriseSearchServiceApplication

$out=Get-SPEnterpriseSearchStatus –SearchApplication $ssappn[0].Name

 

 

if ($out.State -eq 'Active')

{

  Write-host "Message: Search Index is active!";

  Write-host "Statistic: $stat";

  Exit 0;

  }

  Elseif

($out.State -eq 'degraded')

{

  Write-host "Message: Search Index is degraded!";

  Write-host "Statistic: $stat";

  Exit 1;

  }

 

However, i don't know how i would filter out just one line to check for the status. I really only care if the Index is Degraded

Powershell - Output Critical

$
0
0

I am trying to run a Powershell monitor that outputs data from a SQL select statement, so that I can use the data in my alert bodies.

 

The below script runs against my database, and outputs a statistic value in char form.

 

$results = Invoke-Sqlcmd -Query "set nocount on;begin select ip.policyno as [Stat1]

from i1.dbo.DD_InstalmentPlan ip where ip.Status IN ('L', 'F', 'D', 'N')

end " -ServerInstance "********************" -Username "*********" -Password "*******"

$statistic1 = $results  | select -expand Stat1

write-host "Statistic.Stat1: $statistic1";

 

How do you get the output to be critical when it outputs a char rather than an integer?

 

Thanks

Alert Execute Program Trigger Action

$
0
0

Hello everyone, I am trying to execute a powershell script as a trigger action. In my file path I have \\servername\C$\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -executionpolicy remotesigned -command C:\scripts\swpstest.ps1 -ComputerName ${N=SwisEntity;M=Caption}

 

My question is what method do I need to put into the powershell script in order to retrieve this parameter (node name)? Is it $args[0] ? Or param([string]$x) ?

 

For the path above I have also tried C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -executionpolicy remotesigned -command "C:\scripts\swpstest.ps1" -x "${N=SwisEntity;M=Caption}"

 

Any one know what I am doing wrong?

Is Solarwinds SAM support monitor HP OpenVMS system process?

$
0
0

Hi All,

 

Is Solarwinds SAM support monitor HP OpenVMS system process job? I have 1 customer using OpenVMS server and running batch file job. they using 1 single file to running multiple jobs. Currently, they want to use Solarwinds to monitor each of the job and alert them which of the job is stopped.

 

I had tried use the Solarwinds SAM out-of-box application template call "linux process check" to monitor each of the job but fail. The OpenVMS system is not a Linux OS.

 

Is anyone try on OpenVMS system before?


Reboot report with whom & when

$
0
0

Hi All,

 

We are taking last 24 hours reboot report daily, I would like to add who rebooted and reason for the reboot on that report.

 

Can someone help me how to add those details in a report.

 

 

Thanks in advance.

Automate config push for Crypto Pki trustpoint

$
0
0

Looking for suggestions/help on how i can push the following commands to all my routers automatically where script automatically grabs the router hostname "fqdn HOSTNAME.mydomain.com" and pushed the following commands and also authenticate and enroll to the new CA.

 

 

crypto pki trustpoint testca

enrollment url http://testcacert.com:80

serial-number none

fqdn HOSTNAME.mydomain.com

revocation-check crl

rsakeypair Hostname  2048 2048

 

crypto ikev2 profile IKeINET2PROFILE

match fvrf INET2

match identity remote address 0.0.0.0

authentication remote rsa-sig

authentication local rsa-sig

pki trustpoint testca

 

 

crypto pki authenticate testca

 

!! wait for 15 sec

!! Type Yes and hit Enter

 

crypto pki enroll testca

! Hit Enter three times

Hit Enter

Hit Enter

Hit Enter

! type Yes and hit Enter

Yes

 

exit

wr mem

Monitoring SCCM Update Deployment Help Requested

$
0
0

I am trying to setup a apm template to monitor som aspects of SCCM update deployments to servers.

 

the one part i need help on is formatting the pending update returned values. The PS string to return the pending updates is

(Get-WmiObject -Query "SELECT * FROM CCM_SoftwareUpdate" -Namespace "ROOT\ccm\ClientSDK")

 

which would return this (Several of these, depending on number of pending updates)

 

 

__GENUS                     : 2
__CLASS                     : CCM_SoftwareUpdate
__SUPERCLASS                : CCM_SoftwareBase
__DYNASTY                   : CCM_SoftwareBase
__RELPATH                   : CCM_SoftwareUpdate.UpdateID="Site_D0249E54-EC0C-44EA-B097-993DA68D3E4F/SUM_6ddd239d-3161-                              4d68-92cc-fadef38ea6eb"
__PROPERTY_COUNT            : 25
__DERIVATION                : {CCM_SoftwareBase}
__SERVER                    : CRN-SOL-02
__NAMESPACE                 : ROOT\ccm\ClientSDK
__PATH                      : \\\ROOT\ccm\ClientSDK:CCM_SoftwareUpdate.UpdateID="Site_D0249E54-EC0C-44EA-B097                              -993DA68D3E4F/SUM_6ddd239d-3161-4d68-92cc-fadef38ea6eb"
ArticleID                   : 3020338
BulletinID                  :
ComplianceState             : 0
ContentSize                 : 0
Deadline                    : 20150215023400.000000+000
Description                 : Install this update to resolve issues in Windows. For a complete listing of the issues                              that are included in this update, see the associated Microsoft Knowledge Base article                              for more information. After you install this item, you may have to restart your computer.
ErrorCode                   : 0
EstimatedInstallTime        :
EvaluationState             : 0
ExclusiveUpdate             : False
FullName                    :
MaxExecutionTime            : 600
Name                        : Update for Windows Server 2012 (KB3020338)
NextUserScheduledTime       :
NotifyUser                  : True
OverrideServiceWindows      : False
PercentComplete             : 0
Publisher                   : Microsoft
RebootOutsideServiceWindows : False
RestartDeadline             :
StartTime                   : 20150214223400.000000+000
Type                        : 2
UpdateID                    : Site_D0249E54-EC0C-44EA-B097-993DA68D3E4F/SUM_6ddd239d-3161-4d68-92cc-fadef38ea6eb
URL                         : http://support.microsoft.com/kb/3020338
UserUIExperience            : True
PSComputerName              :

 

 

I would just want the Name and URL returned in the message field.

 

Anyone have any suggestions on how to accomplish this feat?

File Count Powershell

$
0
0

Hello,

I have some troubles with a custom file count script. The script should alert me when there is no new file in the directory for about 60 minutes.

 

Script:

 

$path = '\\server'

$stats = 0

$msg = ''

$days = 0

$hours = 3

$minutes = 0

$files = @(Get-ChildItem -Path $path)   

 

if ($files -ne $null) {

  $f_names = [System.String]::Join('|',$files)

  $msg = 'Message: ' + $f_names

  $stats = $files.Count

} else {

  $msg = 'Message: 0 files exceed defined age'

}

 

 

Write-Host $msg

Write-Host "Statistic: $stats"

 

 

 

The main problem is, the script is working fine and also counts the files.

 

But I´m not sure how to setup the static threshold to get the notifications. Is there a way to use a variable or something like this int the warning /less than field or something like that ?

 

 

 

Thank you very much!

Netapp Powershell monitoring

$
0
0

I've installed the netapp powershell commands on the Orion server.  The Netapp toolkit can be found here https://communities.netapp.com/docs/DOC-6138.  I'm able to run the script below in a powershell window directly from the Orion server (replacing solarwinds variable ${IP} with actual filer name) and it runs properly.

Connect-NaController '${ip}'

 

$VolArray = get-navol | where {($_.name -notcontains ".snapsshot")}

 

foreach ($vol in $VolArray)

{

$name = $vol.Name

$percent = $vol.Used

 

# This is important - Solarwinds requires a "Unique identifier" for

# each value returned by a script. The line below creates an

# identifier for each result returned.

Write-Host "Statistic.$name :" $percent

}

Here is the error output in SAM

Errors: ==============================================

Connect-NaController : Failed to load ntapadmin64 DLL

At line:1 char:1

+ Connect-NaController '10.80.0.40'

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidResult: (10.80.0.40:NaController) [Connect-NaController], Exception

+ FullyQualifiedErrorId : RpcConnectionFailed,DataONTAP.PowerShell.SDK.ConnectNaController

 

get-navol : Value in $global:CurrentNaController is not of type NetApp.Ontapi.Filer.NaController

At line:3 char:13

+ $VolArray = get-navol | where {($_.name -notcontains ".snapsshot")}

+ ~~~~~~~~~

+ CategoryInfo : InvalidArgument: (:) [Get-NaVol], ArgumentException

+ FullyQualifiedErrorId : ControllerNotSpecified,DataONTAP.PowerShell.SDK.Cmdlets.Volume.GetNaVol

Here are the results from PS windows on the server.

Name                 Address           Ontapi   Version                                                                                   

----                 -------           ------   -------                                                                                   

aus-nas1.corp.nat... 10.80.0.40        1.19     NetApp Release 8.1.2 7-Mode: Tue Oct 30 19:56:51 PDT 2012 

                              

Statistic.aus_callrec_orkaudio : 90

Statistic.aus_callrec2_orkaudio : 13

Statistic.ausshare : 84

Statistic.aususers : 62

Statistic.avaya_http_SnapMirror : 32

Statistic.Backups : 2

Statistic.callrec_orkaudio_legacy : 84

Statistic.callrecs : 89

Statistic.DeploymentShare_SM : 78

Statistic.kshare : 67

Statistic.lhlab : 1

Statistic.nycshare_SnapMirror : 86

Statistic.outrank : 71

Statistic.phx_callrec_orkaudio : 89

Statistic.prodmssql_backups : 0

Statistic.sellfire : 9

Statistic.software : 89

Statistic.vmware_nfs1 : 86

Statistic.vol0 : 4

3Com 4400 script

$
0
0

Newbie here, looking to script changes to create logging for syslog on menu driven 3Com 4400s. Commands are as follows when using menus from login:

 

sys

man

log

 

'The script gets messy as the inputs do not take properly:

'begins asking logging selections

cre

 

'From here, options as follows:

 

Enter log server name: abc
Select log server type (syslog)[syslog]:
Log SNMP events (enable,disable)[disable]: e
Log CLI events (enable,disable)[disable]: d
Log RMON events (enable,disable)[enable]: d
Enter syslog server IP address: 192.168.1.1
Enter syslog server UDP port (1-65535)[514]:

 

Select menu option (system/management/log):

 

Menus do not seem to move from selection fast enough to accept input changes. Any ideas are greatly appreciated!

Count of files matching a filename pattern.

$
0
0

We have a request from a server owner to monitor for the count of files matching a specific filename pattern, and to generate an alert when that count is exceeded. Currently that group is handling this via batch file, and would prefer to handle it through SAM for obvious reasons.


We need to generate alerts for the following file name patterns:

  1. For XML49 files the share used:  \\servermame\path\to\file\49*OUT.*
    For XML81 files the share used: \\servermame\path\to\file\81*OUT.*
  2. XML49 file threshold is 10 and for XML81 the threshold is 50.
  3. They have been monitoring every 10 minutes but this can be changed.

 

The batch file they are currently using is as follows:

 

@ECHO OFF

REM J. Rissmiller Monitor XML49/81 Files in Specified Directory

REM v1.0: 140626 - Initial Release of Monitoring

REM v1.1: 140703 - Split output to separate text files, reformat date/time and add Tab character for Excel

 

SETLOCAL

SETLOCAL ENABLEDELAYEDEXPANSION

 

REM COUNT XML49 FILES

SET count49=0

for %%o IN (\\servermame\path\to\file\49*OUT.*) DO (

                REM echo %%o

                SET /A count49=count49 + 1

)

 

 

 

REM COUNT XML81 FILES

SET count81=0

for %%o IN (\\servermame\path\to\file\81*OUT.*) DO (

                REM echo %%o

                SET /A count81=count81 + 1

)

 

REM Calculate Timestamp and Send Counts to Monitor49.txt & Monitor81.txt

For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)

For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a:%%b)

 

 

 

echo %mydate% %mytime% %count49% >> monitor49.txt

echo %mydate% %mytime% %count81% >> monitor81.txt

ENDLOCAL ENABLEDELAYEDEXPANSION

ENDLOCAL

 

Is anyone doing something similar? If so, would you be able to share a script with me and/or tell me how I might go about accomplishing this? I've posted this in the SAM forum; we also have NPM and LEM at our disposal if either of those help.


Any guidance is greatly appreciated. Thanks.


ASP.NET Web App under SW Site

$
0
0

Hi all,

I am not sure there is right forum. I just have an question about ASP.NET web application. The web application is published under SolarWinds Orion Web Site but is located physically another folder. I just got an error "Could not load type 'SolarWinds.Orion.Web.HttpModules.WebProxy'". I think there is a dll file about that but I can't this file. Can you any suggest about that error?

 

ss.png

 

ss2.png

How to create a vbscript that runs a batch file on a remote server?

$
0
0

How to create a vbscript that runs a batch file on a remote server?

 

I have a requirement to create a vbscript that runs a batch file (when triggered on a certain condition) on a remote server.

I have the basic vbscript written and I added it into SAM. That part works fine (the vbscript checks if disk space >5% and if so then send some output).

 

The part that I am having trouble with is how to have it run the batch file (remotely) when triggered by the vbscript.

 

Any help will be appreciated.

 

Thank you

-Gino

Creating an array in a powershell script

$
0
0

I am trying to figure out a way to dynamically create an array from several variables inside of a powershell script.

 

I have several variables that will be deffined

 

$svr_list1 = "svrA", "svrB", "svrC"

$svr_list2 = "svrD", "svrE"

$svr_list3 = "svrF", "svrG"

 

$svc_list1 = "svcA", "svcB"

$svc_list2 = "svcA", "svcC"

$svc_list3 = "svcD"

 

I am trying to figure out some list that can pull these together into a single array but only have single groups line up so all servers in svr_list1 will only get the services in svc_list1, list 2 will line up, etc

 

 

$arry =   [svrA][svcA]

               [svrA][svcB]

               [svrB][svcA]

               [svrB][svcB]

               [svrC][svcC]

               [svrC][svcB]

               [svrD][svcA]

               [svrD][svcC]

               [svrE][svcA]

               [svrE][svcC]

               [svrF][svcD]

               [svrG][svcD]

 

 

I would like to loop this so that i can just update my original variables that are used elsewhere and then this loop would pull together the appropriate list without having to manage it twice. 

Powershell file size monitors

$
0
0

This is probably an easy one, I just admittedly don't know the first thing about PowerShell but I need to get some monitors built.

 

I've got some commands that do something close to what I want but I don't know how to make them output as statistics so SAM can use them.

One is to check directory size, the other is to check the filesize of the largest file in the directory.

 

This is what I have currently:

Directory size:  Get-ChildItem C:\Windows | Measure-Object -property length –sum

Largest file in directory:  Get-ChildItem c:\Windows | Sort Length -desc | Select-Object -first 1

 

How do I get them to give me statistics instead of the current output?

 

Thanks!

Problem with Output Statistic

$
0
0

Greetings,

 

I'm working on a powershell monitor to monitor IIS App pools and restart if necessary, however, I'm getting "no output detected" for some reason. I've done a few of these using similar methods and haven't had any issues, is anyone able to point out any obvious reasons? Here's the script -

 

$Servers = "VBMDEAPP512"

 

  #Get Application pool froom remote server

   $AppPools = gwmi -namespace "root\webadministration" -Class applicationpool -ComputerName $Server -Authentication PacketPrivacy -Impersonation Impersonate  | Where-Object {$_.Name -like 'awstats' -or ($_.Name -like 'Repliweb') }

   Foreach ($AppPool in $AppPools){

 

    #Check Status of App Pool, Status returns 0 to 4 and these refers to above descripted state

    if ($AppPool.GetState().ReturnValue -eq 4){

     Write-Host  "Message.4: $($AppPool.Name) $Server Unknown State"

     Write-Host "Statistic.4: 4"

     }

   

    if ($AppPool.GetState().ReturnValue -eq 3){   

     Write-Host "Message.3: $($AppPool.Name) $Server Stopped State and we're starting it"

     Write-Host "Statistic.3: 3"

     $AppPool.start()

     }

 

 

    if ($AppPool.GetState().ReturnValue -eq 2){     

    Write-Host "Message.2: $($AppPool.Name) $Server Stopping State"

    Write-Host "Statistic.2: 2"

    }  

   

    if($AppPool.GetState().ReturnValue -eq 1){

    Write-Host "Message.1: $($AppPool.Name) on $Server" "is Running"

    Write-Host "Statistic.1: 1"

    }

 

 

}

 

Thanks!

Viewing all 9937 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>