Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all 6937 articles
Browse latest View live

WMI Remote Repair

$
0
0

Hello,

I'm looking to write a script to remotely repair WMI.

So far this is what I have.

Invoke-Command -Computername $PC -scriptblock {net stop winmgmt /y}

Invoke-command -Computername $PC -scriptblock {regsvr32 $env:systemroot\system32\scecli.dll}

Invoke-command -Computername $PC -scriptblock {regsvr32 $env:systemroot\system32\userenv.dll}

$AllDll = get-childitem -path \\$PC\C$\Windows\System32\wbem -recurse -include *.dll

foreach($dll in $AllDll){

invoke-command -Computername $PC -scriptblock {regsvr32 /s $dll}

}

$AllMofmfl = get-childitem -path \\$PC\C$\Windows\System32\wbem -recurse -include *.mof,*.mfl

foreach($item in $AllMofmfl){

invoke-command -computername $PC -scriptblock {mofcomp $item}

}

or would it be easier to only call one invoke-command with everything in the script block?

Thanks for your help


Powershell scripts with html - can these be run using IIS?

$
0
0

Simple question

Powershell scripts with html - can these be run using IIS?

I have some scripts that are going to be used as a service status dashboard. 

Thanks

Install .exe remotely on domain computers

$
0
0

Hi!

I really need to know how to install an exe file on several domain computers located in a shared folder.

Can you help me with this??

I'm new to Powershell and really don't have any clue...

Thanks!!

Clear Azure Subscriptions with No ID from PowerShell

$
0
0

Q: I'm using PowerShell with Azure, but I have a subscription with no subscription ID. How do I clear that subscription from Azure?

A: I've seen a few environments that have a subscription as part of the environment, with no subscription ID. This doesn't actually work when you try to run PowerShell against it. The exact cause is unclear; however, running the following command will confirm the details of all known subscriptions.

Read More

Upload powershell book - excerpt of tips and tricks from powershell.com/blog

$
0
0

Out out my love towards powershell I have created a simple e-book with simple to the point approach.

I would like to post that book here so that if any one wants, they can have a look at it.

Actually I created a book of all power tips posted in this site because the monthly book was good but its too heavy on memory and size which my computer couldn't handle good so I have created this book which is around 6.5MB.

Actually started for myself to read it sometime later but later felt that it might be useful for someone with similar requirements.

PowerShell using SMO - how to look at the query results?

$
0
0

This code worked well with PS 4.0, and .net 4 something. But when I try to execute it on another machine the FOREACH gets an indexing error.

Guess my first question is (1) after executing the ExecuteWIthResults, how do you look at the individual row/column values returned?  (2) what problems will I run into moving a SMO solution between different .NET versions?

 

[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
$sqlsvr
='fidev360x\fidev360x'
$dir
='c:\temp\pssmo\'
$database = '
aaatest'
$diagnostics = 1
$sqlserver = New-Object Microsoft.SqlServer.Management.Smo.Server($sqlsvr)
$db = $sqlserver.databases[$database]
$Tables = $db.ExecuteWithResults("Select * FROM ifs_exporttables")
foreach ($DataRow in $Table[0].Tables[0].Rows)
    {
    $TableName = $DataRow[2].tostring()    # ifs_ExportTables.TableName
    $Delimiter = $DataRow[4].tostring()    # ifs_ExportTables.Delimiter
    $Header = $DataRow[5].tostring()       # ifs_ExportTables.ColumnHeaders
    if ($diagnostics = 1)
        {write-host -ForegroundColor Green "Creating Table $TableName to path $dir$TableName.csv" }
    $sqlserverR = New-Object Microsoft.SqlServer.Management.Smo.Server($sqlsvr)
    $dbR = $sqlserverR.databases[$database]
    $TablesR = $dbR.ExecuteWithResults("Select * FROM $TableName")
    $result = $TablesR[0].tables.item(0)
    if ($Header -eq '
1')
    {$result |export-csv -Delimiter $Delimiter –notype -path $dir$TableName.csv  -Encoding ASCII}
    else
    {$result | ConvertTo-Csv -NoTypeInformation -Delimiter $Delimiter | Select-Object -Skip 1 | Out-File -FilePath $dir$TableName.csv  -Encoding ASCII}
    }

 

 

Which class to export data from SQL Table to flat file?

$
0
0

Need to read 85 SQL tables and export them to a delimited flat file with a header.  I cannot use bcp or invoke sqlcmd. Has to work with SQL 2005 - 2014. Will execute from a SQL Agent job.

I have seen some partial examples with smo, serverconnection, sqlconnection with adaptor. Any others that I am missing.

What are the pros and cons of the various classes? Which is the most portable? The solution will be sent out to several clients and I have no control over their os, .NET, PS version. (I can force probably force the .NET and PS, but would prefer not to do it too often)

CHANEL包包 pevi fxx bvwdc

$
0
0

不死利刃魔挨了幾刀,不斷的慘叫,身體又彈出23道閃電來,每隻骷髏兵身上又多了兩道電羽,電羽放射的電流如煙花般美麗,耀眼。但骷髏兵還是在揮刀砍不死利刃魔,如此持續了3秒鐘,骷髏兵全部斃命,不死利刃魔則不停的大罵起來,閃電不停的四處飛濺,如果離不死利刃魔近,很難躲得掉密集的電羽攻擊。雲正要發牌,不料已有一道電羽貼在後心,大駭,突然一道紅影從身旁劃過,停在了不死利刃魔身前,那道紅影正是許興跑動的殘影,只見許興雙手掄劍毫不顧密集的閃電, ugg 在台灣要去那裡買CHANEL包包一劍向下砍落,一劍刺不死利刃魔的眼睛,速度之快,不死利刃魔跟本來不及反應,也許不死利刃魔皮囊較厚,那一砍只是輕輕劃破了皮,刺的一劍則如願刺中了 ugg雪靴專賣店 的眼睛。

金色的流光消失後,不死利刃魔已倒在了地上,身上流滿了鮮血。雲走上前去,拔出幾張金牌收回,剩下的金牌則完全沒入身體裡。雲道:玩遊戲的時候不死利刃魔給 ugg代購留下的印象並不深刻,沒想到,挺厲害的嘛,吃了 ugg雪靴專賣店 幾張金牌死了,倒也死的值了,隊長,謝謝你了。許興道:哪裡的話。說完,許興將死掉的利刃魔化形,雲附魂,因為許興穿的不死鎧甲的緣故,他化形出來的骷髏兵樣子雖然沒變,但是骷髏兵的敏捷,力量,生命,都是比以前強了2.

12個骷髏兵在雲附近四處走動,看 ugg雪靴專賣店的樣子是非常的機警,一刻也閒不下來。王介掏出捲軸,按捲軸上標的順序,一一用手貼過石柱上的花紋,每碰一顆石柱,石柱的花紋都會發出黃色的光芒,待摸過最後一顆石柱​​時,天空突然昏暗起來,彷彿太陽給什麼遮住了?絲毫沒有陽光。六道石柱不停的釋放著白色的能量,如一條條活生生的巨龍,紛紛纏繞在一起,聚集起來,將周圍照亮,須臾,白光消失,天空恢復光明,一道金色的橢圓型空間門打開了。

耐吉慢跑鞋 atpa gcp wokda

紐巴倫官網 zcvk boa ryeje

Converse eqjg qiy mzfyt


耐吉 uumi iye gddnl

$
0
0

三道光圈照在牆壁上,如果用直線把 ugg連接起來它就是三角形的形狀了。里昂與許興都思考起來,里昂順手左右搖擺了兩下,當搖擺停止三秒鐘後,那幾道光圈會組合在一起,形成一個新的造型,里昂見沒什麼反映,問許興道: ugg官網 耐吉知道怎麼玩這遊戲麼?許興搖了搖頭,道:這有點難度。雲道:王介, ugg官網 不是很聰明麼, ugg官網 說這要怎麼玩啊?

王介低頭沉入了阿爾法狀態, UGG官方網站道:沒錯,但是只是變了一點點而已,沒什麼的。先搖擺中間的那道,前後搖擺一次,西邊的那個左右搖擺,東邊的那道左右前後搖擺。里昂許興照著王介的提示搖擺,三秒鐘後,那三道光線混合在一起,中間部分形成了一個顯眼的紅色教符,接著,四道鐵門同時開啟,面朝西的那道門後面是一小屋子,許興和里昂迅速跑了過去。

王介笑了笑,道:呵呵,你這樣的表情顯得我太聰明了,這沒什麼。首先 ugg官網要組合出教符是肯定的了。三道光線裡面都缺少一種色彩,這說明了什麼呢?這三樣缺少的部分疊加在一起組合出來的顏色就是紅色了。雲的話還沒有說完,他的嘴巴還張著卻沒有了聲音,閃電映照在他臉上的光影也停留不動,再看張凌,梁玉燕, ugg官網 也都是保持這方才的動作不動,王介鬱悶起來:咦?

Nike Air Max ngwv lnw gaxed

lv官網 nhas xeb rpbgr

[Help] Trying to get the host IP from web server

$
0
0

Ok, there are tons of ways to get IP addresses via Powershell:

What I have is a web server that has several IP's assigned to it as it runs multiple sites. I want to get the actual IP address of the server itself.

There are a ton of ways to get the IP addresses, but the one I found useful is:

(gwmi Win32_NetworkAdapterConfiguration | ? { $_.IPAddress -ne $null }).ipaddress

It lists the IP addresses in a list and is nice an neat with no need to really mess with it.

Now, let's say I have a list of IP's like this:

10.224.97.40
10.224.97.39
10.224.96.36
10.224.96.34
10.224.96.32
10.224.96.30

And the actual IP address of the server is:

10.224.96.36

How can I just get that one IP returned KNOWING it is the server IP and not a site IP?

If I use another method:

[System.Net.Dns]::GetHostAddresses($env:COMPUTERNAME)

I get data like:

Address            : 509665290
AddressFamily      : InterNetwork
ScopeId            :
IsIPv6Multicast    : False
IsIPv6LinkLocal    : False
IsIPv6SiteLocal    : False
IsIPv6Teredo       : False
IsIPv4MappedToIPv6 : False
IPAddressToString  : 10.224.96.30

Address            : 543219722
AddressFamily      : InterNetwork
ScopeId            :
IsIPv6Multicast    : False
IsIPv6LinkLocal    : False
IsIPv6SiteLocal    : False
IsIPv6Teredo       : False
IsIPv4MappedToIPv6 : False
IPAddressToString  : 10.224.96.32

...and so on

There is no real way to tell which is the adapter address...

Using:

gwmi -query "Select IPAddress From Win32_NetworkAdapterConfiguration Where IPEnabled = True"

is worthless as it returns the IP addresses in an array:

__GENUS          : 2
__CLASS          : Win32_NetworkAdapterConfiguration
__SUPERCLASS     :
__DYNASTY        :
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
IPAddress        : {10.224.97.40, 10.224.97.39, 10.224.96.36, 10.224.96.34...}
PSComputerName   :

Any ideas?

Thanks!

Implement Easiest Solution to Restore Windows XP BKF Files In Windows 2007 Os!

$
0
0

Before sometimes, I was encountering Windows BKF file corruption problem because my all XP created (.bkf) file has been damaged and dissolved due to unexpected virus attack. After corrupt BKF file, I did not recover my data from BKF file in easy way. But later some time, I used BKF recovery software which fixes corrupt error of windows XP BKF files instantly. After using this software, I received my all precious information files from damage XP BKF files in few minutes. In additionally, this software can restore windows XP BKF files in windows 2007 OS as well.

Read More:- http://www.bkfrepairtool.com/restore-xp-bkf-in-windows7.html

How to remove braces from Get-CsCertificate cmdlet output and ConvertTo-Html

$
0
0

I'm trying to take the output from get-cscertificate | select-object "alternativenames" which is: 

AlternativeNames

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

{sip.domain.nl, lyncdiscoverInternal.domain.nl, lyncdiscover.domain.nl, sr-xxxxx.vitens.lan...}

When piping this to ConvertTo-Html the output in the Html file becomes:

System.Collections.Generic.List`1[System.String]

The command i use is: Get-CsCertificate | fl 'AlternativeNames', Issuer, NotAfter, SerialNumber, Subject, Thumbprint, Use |

ConvertTo-HTML -head $a -Body "<H2>$Servername Certificate Information $Date</H2>" | 

Out-File C:\Install\LyncCertificateCheck.htm

I know it's because of the {} braces but i can't figure out how to remove or edit or change the formatting.

Anyone?

Desktop icon open URL in specific monitor/ display

$
0
0

Hi,

I'm wondering if it is possible to create an icon on a user's desktop (who will not have local admin rights) which will open a standard http url, wait for the window to load, and then send the "Windows logo key +Shift+Left arrow" command to Move the browser window in the desktop from one monitor to another.

 

Currently I can only set the browser to open in one monitor or another, and cannot say I want this URL to open on the left one, and the default (aka all other URLs) to open in the right.

Thank you for your assistance.

modify file using user input

$
0
0

New to powershell...I need to build a script that will ask the user for a username and a password and put theme in a file and save the file

Send on behalf

$
0
0

Can I send an SMTP message from a Powershell script that performs a "send on behalf" operation?

The Send-Mailmessage Cmdlet doesn't seem to offer that capability (using the "from" option tries a "send as", not a "send on behalf of").

 

Kris.


Check mails

$
0
0

Good day friends,
is there any way that I can check my emails from yahoo and hotmail by powershell?

New feature in Pester 3.0: Code Coverage metrics

$
0
0

I have a confession to make… I don’t actually practice TDD or BDD yet. I see the value of having unit tests, but I’ve been writing scripts for so many years now–most of that time without automated tests–that it’s been difficult to change my habits and get into that 30-second micro cycle of “Red-Green-Refactor”. I still tend to write pseudo code for a function and flesh it out from there, only writing tests when it’s basically done. Shame on me!

Read More

Copying and inserting text from one file into another into a specific place within that text file

$
0
0

Hi All,

I am trying to copy the contents of a file and then paste this content into a specific location within another file. 

I can copy the contents no problem using get-content and then paste the content using the set-content (which i know is not correct as this is overwriting the file) i need to just paste it into the other file after the last <location/> tag.

However, i cannot find anywhere how best to do this?

 

Any help with this is greatly appreciated.

 

Cheers 

Grizzly

Cleaning up a list with duplicate user names.

$
0
0

I have exported a list of last logged on users form Citrix and I need to clean up the list so that each use only shows up in the list once.  Because the users have logged on to different desktops over time, they may have multle entries.  I do need to keep the name of one of the desktops they have logged into because this gives me the name of the Desktop Group they are using. 

Here is an exaple of the text file that I am cleaning up:

KQR\tdarxxx,KQR\ta-secrets-15
KQR\tdarxxx,KQR\ta-secrets-16
KQR\tdarxxx,KQR\ta-secrets-17
KQR\tdarxxx,KQR\ta-secrets-18
KQR\apaxxxa,KQR\ta-vision-01
KQR\dmxxxer,KQR\ta-vision-02
KQR\pzbxxxk,KQR\ta-vision-03
KQR\dmuxxxr,KQR\ta-vision-04
KQR\dmuxxxr,KQR\ta-vision-05
KQR\sprxxxa,KQR\ta-vision-06
KQR\hsexxxa,KQR\ta-vision-07
KQR\hsexxxa,KQR\ta-vision-08
KQR\mxxxan,KQR\ta-vision-10
KQR\mxxxan,KQR\ta-vision-11

once I have KQR\tdarxxx,KQR\ta-secrets-16 , I don't need any more info on him.

This doesn't work:

$chusers = Get-Content -Path C:\test\chusers.txt
$compare = @()
$flist=""
    foreach ($user in $chusers ){
            $temp = $user -match '^KQR\\(\w+)'
            $test = $Matches[1]
                  
                if($flist -notmatch $test){
                        $compare += $user
                   }#end if
  
              
    }#end foreach
    $compare 

 

sending a command to all workstations

$
0
0

Net Send is not part of Windows 7.  They have the MSG command but it is to send messages to users and not really used for computer to computer communication.  Does PowerShell have a way to to mimic Net Send so you can send a broadcast message to all Windows 7 workstations on your network?  

Viewing all 6937 articles
Browse latest View live