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

Powershell v.2.0 to v.3.0

Hi all, We recently updated one of our admin servers to WMI 3.0 and I'm finding that all my PS v.2.0 or earlier scripts are no longer working. Does anyone know how to write a command within the script...

View Article


Finding exactly four numbers

Hello all,        I have a CSV file that I want to find exactly four numbers.  I do not want any numbers with any more or less than four numbers.  I also do not want four numbers attached to any...

View Article


Create contacts frm CSV

Hi,The following script$Path =   'C:\csv\contacts.csv'Import-Csv$Path|ForEach-Object {New-ADObject-TypeContact-Path"OU=Contacts,OU=WLB,DC=Domain,DC=local"-Name"$_.DisplayName"-OtherAttributes...

View Article

find out how many objects i have in a var and members?

Hi all, not sure my terminology is 100% correct here so please tell me if im wrong.  Im hoping to create a dynamic script that will populate excel with the results of any query i run against sql.But im...

View Article

how to find what a Url has been changed to

I am new to Powershell and I have a script that I inherited.  The script opens a URL link and downloads files from the web site to a local path.  The problem is that each month, the URL changes so I...

View Article


compare two folders

Dears,I need to copy the contents of the source folder to destination one if they match, but it copies the whole source file not only the matching sub-folders. I appreciate your support.$Folder1 =...

View Article

Disable powershell console for GUI scripts

Hi All,I have a script to create some GUI dialogbox. When ever i run that script(right click and choose open with powershell) it opens powershell console and then my GUI dialog box. Do we have any way...

View Article

Exporting AD Groups and members to XML

I'm working on a script to export the memberships of a set of AD groups to XML. I've got something that works at a fairly basic level, with the group members at a lower level. However, the group...

View Article


PSobject usage and how to add notes to csv ouput

Hi everyone,I have tried searching how to make a custom csv ouput using powershell. I got a sample script below and it works displaying the Location Name and Location URL as you can see in the sample...

View Article


Add a zero to the front of a number.

I need to add a zero to the front of a number, but only if that number is less than two characters. Here is what I have as of now: Import-Csv C:\WORK\MATCH_TRANSIT_POWERSHELL\done.csv | ForEach-Object...

View Article

Automation in DOwnloading some files from websites using powershell

Hi,I am facing problem to download some files(such as pdf files) having name of all files from internet websites using powershell.i am facing problem because when we serch for one files urls of dites...

View Article

Add up values in column

I have 20 csv files, all with 2 columns.I can grab the lines i need with the code below. I now need to add up the values in the 2nd column of the output.  Can anyone help provide the code needed for...

View Article

Connected Printers inventory

Hi all, I am trying to get an inventory of a list of connected printers on all of my users computers. I am using this:Get-WMIObject -Class Win32_Printer -Computer localhost | Select...

View Article


Pass variable string to Invoke-SqlCmd

Hi, I need call Invoke-Sqlcmd and pass the query in the form of avariable eg.$querycommand = "backup database MH to disk = 'c:\MH.bak' with copy_only, init"Invoke-Sqlcmd -Query...

View Article

Populate Manager DN

I have the following Situation:I have users, that have an Extension Attribute called "ExtensionAttribute1" where on the user  the Manager employeID is saved (come from HR).Now i want to search the...

View Article


Returning SQL result to a powershell variable

Hi, I have a sql command which returns the value 61529CREATE TABLE #TMPFIXEDDRIVES ( DRIVE  CHAR(1),  MBFREE INT)  INSERT INTO #TMPFIXEDDRIVES EXEC xp_FIXEDDRIVES  select top 1 cast(mbfree as int)...

View Article

restart computer remotely

Hi,Does any one have a script that reboot computer from a text file remotely and create an output csv file

View Article


Array within array out to CSV

Hi all,I'm having some trouble understanding how I can get my array output information into CSV.I've written a small script to read a file and populate an array of Analysis Services Servers, for each...

View Article

Remoting - Reporting on more than one service, sending email in html format

Hi - I have a script that works great and looks like this below.  The problem is that I only want to know when anyone one of those services is stopped.   Can anyone assist?[string]$Body=Invoke-Command...

View Article

formatting strings

I need to create a new registry key and I need double quotes to go around what I write to the registry. $Value="cscript c:\windows\MGH\Machine Printer.vbs" I need to write that to the registry but the...

View Article
Browsing all 10624 articles
Browse latest View live