Quantcast
Channel: PowerShell General
Viewing all 10624 articles
Browse latest View live

Start powershell script on Schedule Windows Server 2012

$
0
0

Hello respected powershell scripters.

I stucked with a problem.

I have a script which prints pdf files from a directory with Adobe Reader.

When I start it from the command file with sintax

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -noprofile -noninteractive -File "C:\scripts\ftp_printing_adobe_test.ps1"

It works.
When I add this command file to execute by Schedule, printing don't happen.

I tryed to set any combination of switches in command line after poweshell.exe it didn't work by schedule.

 

Also I tryed to start powershell.exe as ap programm in schedule with parameters --File "C:\scripts\ftp_printing_adobe_test.ps1". With a working directory C:\scripts\. Nothing went out from printer,

 

Can you help me to solve the issue?

 

PS Example of printing files from directory is http://powershell.com/cs/blogs/tips/archive/2011/11/29/print-all-pdf-files-in-folders.aspx


Powershell - Automation/Active Directory SME – Hedge Fund – London – Contract

$
0
0

Hi Guys, this is my first post and I specialise in hiring professionals in the Financial Services Technology space and have a client who I am working with who approached me about the below Powershell opportunity. As a specialist Powershell community I thought this would be the bets place to find a Powershell guru.

The opportunity is a Powershell - Automation/Active Directory SME – Hedge Fund – London – Contract

Hedge Fund, WinTel, DevOps, Development, Operations, SQL, C#, Development, Active Directory, Contract, London, Infrastructure, Networking, Application Support

Harrington Starr are working with one of the world’s leading and most innovative Hedge Funds in their search for a Powershell Automation Guru / SME.

The position will be focused on Active Directory Engineering and PowerShell Automation.

Senior Active Directory Services Engineer is responsible for daily management of AD, AD Federated Security Services ADFS 2.0, IdM solutions 3rd party or home grown and other services participating on the authentication infrastructure.

Candidate MUST have strong Power Shell scripting experience as well as operational responsibility over the Active Directory, DNS, DHCP and PKI services.

In addition to the daily management, will also be involved in initiatives, as project leader or technical resource in order to participate on creating and deploying new solutions, or to improve existing ones.

Responsibilities Duties

·        Run operations of the Directory Services infrastructure and support problem solving for directories, applications and other solutions owned by the Directory Services team

·        Lead the problem management for recurrent or complex issues.

·        Contribute to the development of Directory Services automation processes for support of daily operations and the gathering of directory performance information.

·        Provide an accurate analysis of business requirements and select the most appropriate solution to fulfil them.

·        Based on personal expertise, review current Directory Services solutions and propose improvements participate to their deployments and document them at all stages of evolution.

·        Manage"crisis situations" to a satisfactory conclusion and under stress.

·        Follow all set procedures and policies pertaining to the Change Management system.

Technical Skills & Experience

·        Extensive experience of strong PowerShell Automation

·        Expert level knowledge of PowerShell.

·        Relevant practical experience managing, troubleshooting authentication services

·        Knowledge of Active Directory, DNS, DHCP.

·        Experience with implementation of backup restore and disaster and recovery strategies.

·        Understanding of security concepts related to Public Key Infrastructures.

·        Understanding of identity lifecycle solutions and experience

·        Advanced level Active Directory experience

·        Excellent troubleshooting and fault-finding skills

·        Desirable C# Knowledge

·        Demonstrate the ability to work in an open way, willingness to share knowledge and resources and to educate others within a global team.

·        Be interested in and always keep progress in IT infrastructure technology.

·        Good documentation and presentation skills.

·        Ability to work independently.

Hedge Fund, WinTel, DevOps, Development, Operations, SQL, C#, Development, Active Directory, Contract, London, Infrastructure, Networking, Application Support

 

Powershell - Automation/Active Directory SME – Hedge Fund – London – Contract

If this opportunity sounds interesting to you, please get in touch with me at: richard dot twumasi at harringtonstarr dot com

I wish you all the best.

Thanks

Richard Twumasi

Problems identifying Hidden files and deleting them from an imported list

$
0
0

Hey all.. 

I received a list of files from a customer and i'm  importing the list as a csv and then identifying if they are there and then deleting them.  One problem, it's not picking up the hidden files properly and is identifying them as not being there..

 

Here's the code

 

 

$i= ipcsv c:\file.csv | select new_path
$i | % {
$srcpath=$_."new_path"
if (gci $srcpath-ea"silentlycontinue") {
ac -path c:\temp\deleted_files.txt-value"Found path: $srcpath deleted"
del $srcpath-whatif
} else {
ac -path c:\temp\files_not_exist.txt-value"Path: $srcpath Not found" }
}
I have tried gci -attributes hidden, but it's not working the way i expected
any help would be greatly appreciated

How many days have past since last workday

$
0
0

I have a script that queries a Oracl SQL Database for information going back X amount of days and has to be executed only on work days. I have resolved half problem by using a function I found on this forum:

(http://powershell.com/cs/forums/t/11979.aspx)

function IsTodayWorkingDay

{

      $today = Get-Date -Format d

    if (($today.DayOfWeek -eq [System.DayOfWeek]::Saturday) -or 

        ($today.DayOfWeek -eq [System.DayOfWeek]::Sunday))

    {

        #weekend today 

        return $false

    }    

 

    #Holidays

    $holidays ="04/05/2015","25/05/2015","31/08/2015","25/12/2015","28/12/2015","01/01/2016"

 

    if ($holidays -contains $today) 

    { 

        #holiday today

        return $false

    }

    #none of the conditions above is met, it must be working day today

    return $true

}

If (IsTodayWorkingDay)

{###start this script with SQL query}

Else {Write-Host "It is a holiday"}

 

As it stands now the scripts runs a query that retrieves information for last 1 day(s). I can change this 1 day to a variable but not sure how to pass the amount of days needed.

 

As example:

8th of May is Friday and a work day and I know that it has been 1 day since I ran the script with SQL query. So in the SQL query I wold put in 1 day to go back.

9th of May is Saturday and that is a holiday and the script with SQL query will not be executed based on the "IsTodayWorkingDay" function.

11th of May is Monday and a work day and I know that it has been 3 days since I ran the script with SQL query. So in the SQL query I wold put in 3 days to go back.

25th of May is Monday and a Public holiday and the script with SQL query will not be executed based on the "IsTodayWorkingDay" function.

26th of May is Tuesday and a work day and I know that it has been 4 days since I ran the script with SQL query. So in the SQL query I would put in 4 days to go back.

29th Of December is Tuesday and a work day and I know that it has been 5 days since I ran the script with SQL query. So in the SQL query I would put in 5 days to go back. (Xmas)

 

 

So I need to calculate the amount of days since the last time the script with SQL query got executed and pass the number of days to SQL query through variable as int.

Any help is much appreciated.

 

 

 

 

 

PowerShell to check files and send e-mail notification

$
0
0

Hello Experts,

I am fairly new to PowerShell, but must say I am impressed by what the tool can accomplish, so I expect to learn a great deal more and become more proficient as time goes on.

Scenario:

I need to check if a certain file exists, was created today, and actually has content.

  • If the file does not exist, or was not created today, an e-mail should be sent that states "File not created" or similar.
  • If the file exists and was created today, but has no content, no e-mail should be sent.
  • If the file exists, was created today, and has content an e-mail should be sent that has the contents of the file in the body of the e-mail.

Reason for this request:

I have to check (and keep in sync) user account status (enabled/disabled) in two Active Directory forrests, for which we unfortunately cannot set up a trust. One is the corporate directory (I'll call it directory A) and the other is a separate forrest used to control system access at one of our facilities (I'll call that directory B). The authoritative directory is directory A. Directory B is managed separately, but contains a subset of the users in directory A, so the user accounts match up to a certain extent. When a user account is disabled in directory A, I need to ensure that the corresponding user account in directory B is also disabled (if the user has an account in directory B that is). I figured out how to automate creating a list of accounts that have been disabled in directory A, but are still active in directory B, (that was fun :-)), but rather than rely on someone to run this manually I would like to automate this solution to run daily and send the e-mails referenced above to whomever needs to receive them.

 

For this example:

  • Folder path = c:\Compare_AD
  • File to check for = Accounts_To_Check.txt
  • smtp server = smtp.mailitsomewhere.net

Any assistance you could offer would be greatly appreciated.

Regards

 

 

Strange: "Program 'more.com' failed to run: Object reference not set to an instance of an object"

$
0
0

All,

  The only changes I've made to my W2K12R2 servers is i added some code to my PSH Profile to center my screen and set size/width/font properties.  I also applied the latest round of MS Patches a few weeks back.  I'm trying to use the HELP function of PSH and as you can see below this is the output I get.  Get-Help works, but I need to paginate the output (it's just the way I roll) but the function HELP has hiccuped and I'm stumped.  I do NOT have this problem with my W2K8R2 boxes at all.  All Servers are running PSH 4.0.  Any ideas, thoughts as to what I've run into?

PS C:\Windows\system32> help get-command -Examples
Program 'more.com' failed to run: Object reference not set to an instance of an object.At line:14 char:14
+     $input | more.com
+              ~~~~~~~~.
At line:14 char:5
+     $input | more.com
+     ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

#############################################

PS C:\Windows\system32> help
Program 'more.com' failed to run: Object reference not set to an instance of an object.At line:14 char:14
+     $input | more.com
+              ~~~~~~~~.
At line:14 char:5
+     $input | more.com
+     ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

#############################################

PS C:\Windows\system32> get-help get-command -Examples

NAME
    Get-Command

SYNOPSIS
    Gets all commands.

    -------------------------- EXAMPLE 1 --------------------------

    PS C:\>Get-Command


    This command gets the Windows PowerShell cmdlets, functions, and aliases that are installed on the computer.
    -------------------------- EXAMPLE 2 --------------------------

    PS C:\>Get-Command -ListImported


    This command uses the ListImported parameter to get only the commands in the current session.

Help exporting script results to csv

$
0
0

I'm trying to find a list of backups in Hyper-V and found this script. How can i export the result to .CSV? Thanks

#* Load Veeam snapin

Add-PsSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue

 

## Coleção de vms nos hosts hyper-v

$AllVMs = Get-VBRServer -Name "lx1-vi-hpv-cl3", "lx1-vi-hpv-06" | Find-VBRHvEntity -HostsAndVMs

 

foreach ($VM in $AllVms)

    {$VMBackup = get-vbrjob -Name "NIODO*" | Get-VBRJobObject -Name $VM.Name

        if ($VM.Name -eq $VMBackup.Name)  

            {write-host $VM.Name ";" $VMBackup.Type} 

 

        else {write-host $VM.Name ";Unprotected" }

    }

Scripts result send email

$
0
0

Hi, i need to send email with result of the script.

who help me pls ?

 

the scripts:

$AllVMs = Get-VBRServer -Name "lx1-vi-hpv-cl3", "lx1-vi-hpv-06" | Find-VBRHvEntity -HostsAndVMs

$data = @()

foreach ($VM in $AllVms)

    {$VMBackup = get-vbrjob -Name "NIODO*" | Get-VBRJobObject -Name $VM.Name

        if ($VM.Name -eq $VMBackup.Name)  

            {

                write-host $VM.Name ";" $VMBackup.Type

                $hash = @{

                            VMName = $VM.Name

                            BackupType = $VMBackup.Type

                        }

                $obj = New-Object PSObject -Property $hash

                $data += $obj

            } 

        else {

                write-host $VM.Name ";Unprotected"

                $hash = @{

                                VMName = $VM.Name

                                BackupType = "Unprotected"

                            }

                $obj = New-Object PSObject -Property $hash

                $data += $obj

            }

    }

 

$data | Export-Csv -NoTypeInformation D:\VeeamVMsProtected.csv


2 dimensional arrays

$
0
0

How do I output a 2 dimensional array to a text file?

search for keyword, parse to event log, and write to XML.. (noob warning)

$
0
0

Ok, I'm trying to tackle a problem that a piece of software that monitors for alarms can't apparently do.. and I'm trying to work around it.

I'm a powershell noob, so please pardon my inexperience.

What I need to do is:

  1. Search a folder for all XML that contain the word "Major". 
  2. if it also contain the word "parsedxml" Do nothing and exit. 
  3. else, write.Eventlog -Message ("insert the complete contents the pared XML file") 
  4. then write "parsedxml" to the file so it knows it has already been checked if file still exists in the folder on the next search.

 

I have been working with Kaseya to try and get this done thru their tool and cannot get it to work. I can call a powershell script from Kaseya let's say every 5 minutes, but as I said.. I'm not a programmer by day and need a little help laying out how I would need to do this.

here is where I am at:

I am trying to parse an XML files from a directory where a keyword is defined, if the keyword is found true, take the contents of the xml and post it as the -Message portion of a Write Event and change that keyword so it isn't found the second time the script is run.

THIS WORKS, BUT PARSES EVERYTHING IN THE DIRECTORY.. I NEED TO FILTER ON XML’s ONLY WITH “MAJOR” IN THE FILE

Get-ChildItem C:\test\*.xml | ForEach { Write-EventLog –LogName Application –Source “Verint Alert” 

` –EntryType Information –EventID 1 

` -Message ("Triggered Alarm" + (Get-Content $_))


THIS CODE WILL CHANGE THE VALUE OF THE WORD “MAJOR” to “PARSED”

Get-ChildItem C:\test\*.xml -recurse | ForEach { (Get-Content $_ | ForEach {$_ -replace "Major", "Parsed"}) | Set-Content $_ }

I need to filter only on .xml files contain the “Major”. (Not sure how to do that)
Once the file is parsed, change the name from Major to Parsed so it’s not picked up again on the next check time the script is run.

Powershell and os x servers

$
0
0
Hi there I'm writing a server os info for all our build machines which are a combination of windows, Linux and Mac OS I have managed to get info for windows and Linux by doing get-wmiobject and using SSH modules (import-ssh modules from 3rd party) respectively. When I.m trying to use SSH to connect to a MAC OS x, I get this message Unable to connect to : Exception calling "Connect" with "0" argument(s): "No suitable authentication method found to complete authentication." I have tried various option on google and one of them suggests to call SSH.net directly. How is it possible. Any idea?

Script delete itself

$
0
0

Hi guys

I´m pretty new with powershell and i´m a little bit blind in some things.

I´ve created a script to set up several features and install several pieces of software just running this script. 

For that I´ve allocated a folder in c: drive in my windows 2012 template. 

What I´d like to know if is there any way to delete that folder, script include, once everything is done? I mean, something like add a line at the end of the script and just saying, your last step is delete the whole folder.

Thanks, any help would be really appreciated. 

Diego

 

 

 

 

 

 

Help! Securing Password in Powershell Email Script

$
0
0

Hi All,

 

I'm new at Powershell and having some difficulty with this script below. I cant seem to find a way to run this script without storing the password in the script for my account. I do not want to use the Powershell email cmdlet. 

 

$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) 

$Body1 = (get-content C:\users\Failure.htm) 

$SMTPClient.EnableSsl = $true

$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("username,"Password" ); 

$message = New-Object Net.Mail.MailMessage($EmailFrom, $EmailTo, $Subject, $Body1)

$message.IsBodyHtml = $true;

Using Get-Content to parse log files, need to get the parent file in the list.

$
0
0

I am trying to use Get-Content in the same manner as grep in Linux. I have it working to display the correct data from the files, but I would like it to also include the log file that the data was found in.

 

function Verify(){

Get-Content C:\Users\user\Documents\ScrubbedFiles\*\*.*_scrubbed.txt | Select-String -Pattern ('<data to find>') -AllMatches | Out-File C:\Users\user\Documents\Verification\verified.txt -Width 300

}

Verify

How do I get this to also grab the "parent" log file name that it was found in? It works if I use Select-String by itself, but I can't use that with multiple data fields, <data to find> is a list of about 15 patterns.
Thanks
 

promtforcredentials & catch errors

$
0
0

Hi guys,

I'am on the road of learning powershell and created a first (almost) usefull script. Now I'm running in to a brick wall with error handling.

I created a script for my users to map networkdrives from another domain.

Here is what i've got so far.

Clear-host

$cred = $host.ui.PromptForCredential("IFN Drive Mapper", " Connect to IFN networkshares.
 Please enter your IFN\username and password
 
                     eg. IFN\kaplo", "", "NetBiosUserName")
$username = $cred.username
$name = $cred.GetNetworkCredential().username
$password = $cred.GetNetworkCredential().password
$net = new-object -ComObject WScript.Network
$net.MapNetworkDrive("G:", "\\IFN-fileserver\share$", $false,$username,$password)
$net.MapNetworkDrive("I:", "\\IFN-fileserver\share2$", $false,$username,$password)
$wshell = New-Object -ComObject Wscript.Shell
# checking input
        if ($cred.username.toUpper().startswith(‘IFN\‘) -and $cred.password -ne ('$null')) {
            $clear = $true
            }
       Else {
            $wshell = New-Object -ComObject Wscript.Shell
            $wshell.Popup("Please provide a valid domain\username and password",2,"IFN Drive Mapper")
            }
          
remove-variable cred

function Exists-Drive { 
    param($driveletter) 
 
    (New-Object System.IO.DriveInfo($driveletter)).DriveType -ne 'NoRootDirectory'   

# checking drives   
$d1 = Exists-Drive 'G:' 
$d2 = Exists-Drive 'I:' 

if ($d1 -eq -not $true) {
       $wshell.Popup("Something went wrong, your G: share is not mapped",2,"IFN Drive Mapper")
       }
else {
       $wshell.Popup("Your NFI drive G: is mapped",2,"IFN Drive Mapper")
       }

if ($d2 -eq -not $true) {
       $wshell.Popup("Something went wrong, your I: share is not mapped",2,"IFN Drive Mapper")
       }
else {
       $wshell.Popup("Your IFN drive I: is mapped",2,"IFN Drive Mapper")
       }
      
# exit if user selected cancel/escape 
if (!$cred) { 
    $wshell.Popup("Valid credentials must be supplied to continue. Exiting the program. You can re-run this by starting IFN Drive Mapper",3,"IFN Drive Mapper")   
    #exit 

Now i realy want to catch the error " Exception calling "MapNetworkDrive" with "5" argument(s): "The specified network password is not correct". and put this in a info pop-up box.

Any ideas?


Pick the last object on a list

$
0
0

I query each domain controller to get the last log time for a user on that DC. I do this because I need the exact times.  I get four times, $DC01 to $DC04, returned which I can sort like so

$LastDate="$dc01","$dc02","$dc03","$dc04"

PS U:\> $LastDate

03/01/2015 09:12:24

02/28/2015 10:12:50

03/01/2015 09:12:24

03/01/2015 09:13:10

PS U:\> $LastDate = $lastDate | Sort-Object

PS U:\> $LastDate

02/28/2015 10:12:50

03/01/2015 09:12:24

03/01/2015 09:12:24

03/01/2015 09:13:10

So how would I know create a variable like $LastRecord from the last record in $LastDate

 

Find process owner of multiple processes

$
0
0

The following 2 lines of code work.  But when I try to get the name of the process it returns nothing.

$owners = get-process | Select-Object name, company 

foreach ($owner in $owners) {if ($owner -like '*Sybase*') { write-host "got it" $owner}} 

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

This is not working.  I've tried many things for the Write-Host and I get no errors.  Just no output.

$owners = get-process | Select-Object name, company 

foreach ($owner in $owners) {if ($owner -like '*Sybase*') { Write-Host $_owner.name}} 

What I'm trying to do is this.   We have a suite of tools that has 10 .EXEs.  In Taskman if you view the properties of these .EXEs they are all owned by Sybase.    I want to find all running processes owned by Sybase and then kill them.    This is so we can then copy new .EXE's into the needed folder.

Email a CSV as HTML email

$
0
0

I have this section of code that is trying to convert a CSV file into a HTML email.  It converts to a HTML file fine, I out-put the file and view in a browser, but the string and the email is the raw HTML data.  I assume this is because I haven’t created the string correctly to insert into the email body.  How it looks in the console and the email is the text output at the bottom.  So what have I got wrong?

$htmlformat  ='<title>Matching AD accounts from HR leavers list</title>'

$htmlformat+='<style type="text/css">'

$htmlformat+='BODY{background-color:#FFFFFB;color:#00005C;font-family:Arial,sans-serif;font-size:15px;}'

$htmlformat+='TABLE{border-width: 3px;border-style: solid;border-color: black;border-collapse: collapse;}'

$htmlformat+='TH{border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color:#D6D6F5}'

$htmlformat+='TD{border-width: 1px;padding: 8px;border-style: solid;border-color: black;background-color:#FFFFCC}'

$htmlformat+='</style>'

$EmailBody=Import-Csv-PathC:\PurgeUserRecords\FromHR\LeftIn-$Month.csv|ConvertTo-Html-Head$htmlformat-Body'<h1>Matching AD accounts from HR leavers list </h1>'

Send-MailMessage-Fromadmin@**.**.uk-Subject"HR reported these users as having left CYC in $date"-Tojonathan.hall@**.**.uk-Body$EmailBody-SmtpServer **.**.**.uk

 

 $EmailBody looks like this on the console

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Matching AD accounts from HR leavers list</title><style type="text/css">BODY{background-color:#FFFFFB;color:#00005C;font-family:Arial,sans-serif;font-size:15px;}TABLE{border-width: 3px;border-style: solid;border-color: bla

ck;border-collapse: collapse;}TH{border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color:#D6D6F5}TD{border-width: 1px;padding: 8px;border-style: solid;border-color: black;background-color:#FFFFCC}<

/style>

</head><body>

<h1>Matching AD accounts from HR leavers list </h1>

<table>

<colgroup><col/><col/><col/><col/><col/><col/><col/><col/><col/></colgroup>

<tr><th>DisplayName</th><th>SamAccountName</th><th>EmployeeNumber</th><th>DC01</th><th>DC02</th><th>DC03</th><th>DC04</th><th>LastTrueLogon</th><th>Manager</th></tr>

<tr><td>Young, Sarah</td><td>casepsy</td><td>32081A</td><td>05/12/2014 18:30:06</td><td>13/07/2014 18:32:06</td><td>28/08/2014 11:50:38</td><td>05/12/2014 18:29:27</td><td>12/05/2014 18:30:06</td><td></td></tr>

<tr><td>Mansell, Amanda</td><td>ccsswam</td><td>39670</td><td>15/02/2015 10:39:55</td><td>20/02/2015 11:26:53</td><td>15/02/2015 10:37:17</td><td>20/02/2015 11:24:34</td><td>02/20/2015 11:26:53</td><td></td></tr>

<tr><td>Brown, Sharon(Housing)</td><td>chscasb</td><td>37754</td><td>30/01/2015 12:32:21</td><td>30/01/2015 12:31:37</td><td>29/01/2015 11:27:12</td><td>30/01/2015 12:31:41</td><td>01/30/2015 12:32:21</td><td></td></tr>

<tr><td>Robinson, Louise</td><td>ddtenlr</td><td>35808</td><td>21/04/2015 11:39:18</td><td>17/04/2015 13:55:42</td><td>21/04/2015 08:42:45</td><td>21/04/2015 08:45:55</td><td>04/21/2015 11:39:18</td><td></td></tr>

<tr><td>Shield, Andy</td><td>eedhras</td><td>25841A</td><td>02/02/2015 12:09:25</td><td>03/02/2015 09:49:22</td><td>27/01/2015 16:13:56</td><td>30/01/2015 10:50:34</td><td>02/03/2015 09:49:22</td><td></td></tr>

<tr><td>Foster, Sarah</td><td>eedprsf4</td><td></td><td>Never Connected</td><td>Never Connected</td><td>Never Connected</td><td>Never Connected</td><td>Never Connected</td><td></td></tr>

<tr><td>Phillips, Lisa</td><td>rpbaslp</td><td>31707</td><td>01/03/2015 09:12:24</td><td>28/02/2015 10:12:50</td><td>01/03/2015 09:12:24</td><td>01/03/2015 09:13:10</td><td>03/01/2015 09:13:10</td><td></td></tr>

</table>

</body></html>

Using $PSScriptRoot to call other scripts

$
0
0

$owners = get-process | Select-Object name, company 

foreach ($owner in $owners) {if ($owner -like '*Sybase*') {Stop-Process -processname $owner.name}}

".\$PSScriptRoot\copy.ps1"

The above code works except for the $PSScriptRoot line.  I get no errors.  But the file copy.ps1 is not being run.  copy.ps1 copies a .txt file from c:\temp7 to c:\temp7\1  and the file never shows up.

when I run copy.ps1 all by itself then the .txt file does copy.      so this seems to be a syntax issue.  I've tried without the double quotes and it gives an error.  If I remove the .\ it fails.   what is the correct syntax?

 

Connecting to Linux boxes?

$
0
0

Hi,

As part of the comprehensive server inventory script that i am writing, I realized that it would be great if I can automate the discovery and information gathering of Linux host as well. Is that possible with powershell? I would need to know things like version and edition of the Linux operating system, ram, cpu cores, as well as drive space usage...  I am using Powershell v2.0.

Thank you for your help as always! 

Viewing all 10624 articles
Browse latest View live


Latest Images